Skip to main content
Question

Isolate first line of text using RegEx


Hi @takashi, do you have any ideas on how I would isoloate this first line of text in each 'cluster' of text? I have about 3000 to isolate.....The cluster formats are all the same but the first line of text varies in length.

This information is stored in a text file at the moment and each clusters is separated by 1 character return.

WGS84-YORK_LANDING-CZAC

DESC_NM WGS84 YORK_LANDING CZAC

DT_NAME WGS84

PROJ LM

UNIT INCH

 

WGS84-CASTLEGAR_-CCT3

DESC_NM WGS84 CASTLEGAR_ CCT3

DT_NAME WGS84

PROJ LM

UNIT INCH

 

4 replies

lars_de_vries
Forum|alt.badge.img+10

@tlabelleacc,

It is not clear to me whether the so called clusters are in separate files or can be found within a file.

If it is the latter, I think I would first break up the text by searching for a dubble newline. This can be done using an AttributeSplitter and a ListExploder.

Second, when I look at the texts that are marked bold, I see no white spaces or other similar characters. So you could use a RegEx syntax like ^(.*)?\\s to get the first line or, if you don't want to use RegEx, just repeat the previous step and search for a single newline character and put the first list item in a new attribute. That would probably do the trick as well.

Though I'm not @Takashi, I can only wish to become a grandmaster like him, I do hope it helps you forward.


lars_de_vries wrote:

@tlabelleacc,

It is not clear to me whether the so called clusters are in separate files or can be found within a file.

If it is the latter, I think I would first break up the text by searching for a dubble newline. This can be done using an AttributeSplitter and a ListExploder.

Second, when I look at the texts that are marked bold, I see no white spaces or other similar characters. So you could use a RegEx syntax like ^(.*)?\\s to get the first line or, if you don't want to use RegEx, just repeat the previous step and search for a single newline character and put the first list item in a new attribute. That would probably do the trick as well.

Though I'm not @Takashi, I can only wish to become a grandmaster like him, I do hope it helps you forward.

All the clusters of text are in one TXT File.

 

The AttributeSplitter would create over 6000+ lists as my text file has over 3000 clusters...Unfortunately the RegEx did not return anything through the RegAttributeSplitter?


ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • April 24, 2019

Can you provide a sample of the text file itself? My first thought would be to read the text file line by line and use adjacent attribute handling to isolate the lines you want.

 

keep_after_blank.fmwt


takashi
Influencer
  • April 25, 2019

If the first line always starts with 'WGS84-' and other lines don't, simply you can use a Tester with the "Begins With" operator to isolate the first line.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings