Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
adambrian
Contributor III
Contributor III

remove all words except starting with # or @

Hi Guys,

I want to remove all words where not start with @  or #.
For example :
"I like to #eat McD.. #McD @McDonald"

The result:
"#eat #McD @McDonald"

Thanks,
Adam

8 Replies
Kashyap_R
Partner - Specialist
Partner - Specialist

Hi

Try this

if(WildMatch(ColumnName,'@*','#*')<>0,ColumnName,Null())

Remove Nulls in the option

Thanks

Thanks and Regards
Kashyap.R
Kushal_Chawda

may be this

Data:
Load ID,Data, Concat(if(match(Left(Strings,1),'#','@'),Strings),' ') as FinalString
Group by ID,Data;

Load *,SubField(Data,' ') as Strings;

Load *, RowNo() as ID 
Inline [
Data
"I like to #eat McD.. #McD @McDonald"
];
Vegar
MVP
MVP

Try this,

LOAD 
	Orig, 
	Concat(Manipulated, ' ') as Manipulated 
WHERE 
	WildMatch(Manipulated, '#*', '@*')
GROUP BY Orig
;

LOAD 
	Orig,
	SubField(Orig, ' ') as Manipulated 
Inline [
	Orig
	"I like to #eat McD.. #McD @McDonald"
	"Let's go to #QlikWorld @PhoenixConventionCenter #Arizona"
];
Vegar
MVP
MVP

Oh, I didn't see your answer before posting @Kushal_Chawda . It looks like we have quite similar aproaches. 

It was smart of you to put some kind if ID to the row in case you have multiple rows with the exact same text content. 

Kushal_Chawda

@Vegar   what a coincidence

adambrian
Contributor III
Contributor III
Author

Hi @Kushal_Chawda  @Vegar ,

Thanks for your answer and both can used.. i'll mark as answer the first one.. 

I've another problem.. Currently we used "space" (" ") as split, but some case i need to used "enter" to split it.. Can u 
Ex:

 

2020-01-20 07_21_36-Book1 - Excel.png

 

2020-01-20 07_24_02-Book1 - Excel.png

 

 

Vegar
MVP
MVP

You  can expand your expression for creating the [Manipulated]  field to this:

SubField( SubField(Orig, ' ') , chr(10) ) as Manipulated

//Chr(10) = Enter symbol 

Kushal_Chawda

another option is to replace "enter" to "space"

subfield(replace(Data,chr(10), ' '),' ') as Strings