Skip to main content

Hi.

I have another string replacer question.

I have a file of text strings (appellation) similar to LOT 1/2 DP 17528 LOT 1/2 DP 13552 RS 16932 18812 19986/7 PT 18813 20862  BLK IV KAPUNATIKI SD

I have split the LOT 1/2 DP 17528LOT 1/2 DP 13552 into 4 separate rows

Temp, _result, appellation

LOT 1/2 DP 17528, LOT 1 DP 17528, appellation

LOT 1/2 DP 17528, LOT 2 DP 17528, appellation

LOT 1/2 DP 13552, LOT 1 DP 13552, appellation

LOT 1/2 DP 13552, LOT 2 DP 13552, appellation

 

What I want to be able to do is remove the temp part from appellation  The resultant appellation in this example would be: RS 16932 18812 19986/7 PT 18813 20862  BLK IV KAPUNATIKI SD

I have tried doing this but only ended up removing one part from each instead of both Temp parts.

 

I would be very grateful for any help with this.

Regards, Paul

You can use a StringReplacer in 'Replace Regular Expression’ mode.

For the data you provided the regular expression LOT 1/2 DP \d+  would work (the literal string 'LOT ½ DP ’ - this string ends in a space - followed by one or more digits, followed by a space).

But depending on the rest of your data, you will probably have to change the expression.

 


In your example the string you want to remove always forms the first 8 words of the string.

You can use a StringReplacer to remove the first 8 words with the regular expression ^(\S+\s){8} (from the start of the string, find one or more non-whitespace characters followed by one whitespace character, and this 8 times).

 


Thank you @geomancer . 

That was simpler than I was making it to be!

Regards, Paul


Reply