Skip to main content
Question

Regex string for Attribute Splitter not working.


Forum|alt.badge.img
I am trying to parse out attributes from a autocad layer name for example

 

4 DR-21 PVC C-900 W and are using the following string.

 

 

^([0-9]{1,2})\\s([A-Z0-9]{2,3}-[A-Z0-9]{2,3})\\s([A-Z]{2,3})\\s([A-Z]-[0-9]{2,3})

 

 

Attached are the transformer settings. And trying to go off of what Takashi explained in another post but no luck. It just transfer the complete 4 DR-21 PVC C-900 W to the database fields.

 

It pulls it into groups on Rubular.com but can not get them to split??? any sugestions

 

https://lh4.googleusercontent.com/-NbYXOBTklJU/UkWTEP2CK6I/AAAAAAAAAD0/uMYOFgbx5_Y/s330-o/Attribute_Renamer_Settings.JPG

 

 

https://lh4.googleusercontent.com/-5Fy6rYasiqg/UkWTEN828gI/AAAAAAAAAD0/PbN_5JwgY5g/s330-o/Attribute_Split_Settings.JPG

 

 

https://lh5.googleusercontent.com/-4LGl2OpTA14/UkWTpdHO9qI/AAAAAAAAAEA/9Q-Y_AOYnUM/s330/Rubular.JPG

18 replies

takashi
Influencer
  • September 27, 2013
Hi,

 

 

Regular expression cannot be used as format parameter of the AttributeSplitter.

 

If you need to validate and split the string, consider using the StringSearcher transformer with the regex.

 

Just to split the string at white space, you can use the AttributeSplitter with a white space (not regex) as the delimiter.

 

Takashi

Forum|alt.badge.img
  • Author
  • September 27, 2013
takashi wrote:
Hi,

 

 

Regular expression cannot be used as format parameter of the AttributeSplitter.

 

If you need to validate and split the string, consider using the StringSearcher transformer with the regex.

 

Just to split the string at white space, you can use the AttributeSplitter with a white space (not regex) as the delimiter.

 

Takashi
Takashi,

 

Thank you for your reply(and patience), I have tryied that and the output is just the full layer name? Here is how it is set up with "space" in the Delimeter or format string filed?

 

 

 

 

https://lh4.googleusercontent.com/vh_s-VMA9kPuEShEbzw6JplqeJ9YHepMyUe2rKY0jA=w440-h144

Forum|alt.badge.img
  • Author
  • September 27, 2013
Takashi,

 

Thank you for your reply(and patience), I have tryied that and the output is just the full layer name? Here is how it is set up with "space" in the Delimeter or format string filed?

 

 

 

 

https://lh4.googleusercontent.com/vh_s-VMA9kPuEShEbzw6JplqeJ9YHepMyUe2rKY0jA=w440-h144

fmelizard
Safer
Forum|alt.badge.img+18
  • Safer
  • September 27, 2013
takashi wrote:
Hi,

 

 

Regular expression cannot be used as format parameter of the AttributeSplitter.

 

If you need to validate and split the string, consider using the StringSearcher transformer with the regex.

 

Just to split the string at white space, you can use the AttributeSplitter with a white space (not regex) as the delimiter.

 

Takashi
Hi

 

Try the advanced text editor as shown here:

 

http://docs.safe.com/fme/html/FME_Transformers/Default.htm#Transformers/attributesplitter.htm

 

 


fmelizard
Safer
Forum|alt.badge.img+18
  • Safer
  • September 27, 2013

takashi
Influencer
  • September 28, 2013
takashi wrote:
Hi,

 

 

Regular expression cannot be used as format parameter of the AttributeSplitter.

 

If you need to validate and split the string, consider using the StringSearcher transformer with the regex.

 

Just to split the string at white space, you can use the AttributeSplitter with a white space (not regex) as the delimiter.

 

Takashi
I think you can set a white space to "Delimiter or Format String" by the same way (i.e. pressing a key) as other characters such like comma, hyphen, underscore etc.. Not special, just invisible.

 

Connect a Logger after the AttributeRenamer, and run. How are the attributes logged?

takashi
Influencer
  • September 28, 2013
I think you can set a white space to "Delimiter or Format String" by the same way (i.e. pressing a key) as other characters such like comma, hyphen, underscore etc.. Not special, just invisible.

 

Connect a Logger after the AttributeRenamer, and run. How are the attributes logged?

takashi
Influencer
  • September 29, 2013
I believe the AttributeSplitter with parameter settings like this image would work. A white space is set to the "Delimiter or Format String", although it's invisible.

 


takashi
Influencer
  • September 29, 2013
takashi wrote:
Hi,

 

 

Regular expression cannot be used as format parameter of the AttributeSplitter.

 

If you need to validate and split the string, consider using the StringSearcher transformer with the regex.

 

Just to split the string at white space, you can use the AttributeSplitter with a white space (not regex) as the delimiter.

 

Takashi
I believe the AttributeSplitter with parameter settings like this image would work. A white space is set to the "Delimiter or Format String", although it's invisible.

 


Forum|alt.badge.img
  • Author
  • September 30, 2013
OMG it worked!!! Thank you very much,,, Love this program but can get fustrating at times. Now to to research and learn the concatenator. Thanks again!  

Forum|alt.badge.img
  • Author
  • September 30, 2013
takashi wrote:
Hi,

 

 

Regular expression cannot be used as format parameter of the AttributeSplitter.

 

If you need to validate and split the string, consider using the StringSearcher transformer with the regex.

 

Just to split the string at white space, you can use the AttributeSplitter with a white space (not regex) as the delimiter.

 

Takashi
OMG it worked!!! Thank you very much,,, Love this program but can get fustrating at times. Now to to research and learn the concatenator. Thanks again!  

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • September 30, 2013
What u are doing is sending ur matched parts to 4 variables.

 

As a single space is enough to find these in this your  case, splitting by space is adequate.

 

 

Using your expression in a Stringsearcher u could have aquired your attributes bij exposing 4 elements.

 

 

If the parts would contain spaces, then it wont do of course.

 

 

Writing TLC code in the attributecreator or tester or whatever, is by far more powerfull btw.

 

Like in your case:

 

@Evaluate([regexp  {^([0-9]{1,2})\\s([A-Z0-9]{2,3}-[A-Z0-9]{2,3})\\s([A-Z]{2,3})\\s([A-Z]-[0-9]{2,3})} "@Value(Acad_lyr)" Matched Att1 Att2 Att3 Att4])?"[set Acad_lyrList [list $Att1 $Att2 $Att3 $Att4]]":"no such thing"

 

 

..makes a list in an attribute (when used in the attributecreator)

 

 

 


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • September 30, 2013
takashi wrote:
Hi,

 

 

Regular expression cannot be used as format parameter of the AttributeSplitter.

 

If you need to validate and split the string, consider using the StringSearcher transformer with the regex.

 

Just to split the string at white space, you can use the AttributeSplitter with a white space (not regex) as the delimiter.

 

Takashi
What u are doing is sending ur matched parts to 4 variables.

 

As a single space is enough to find these in this your  case, splitting by space is adequate.

 

 

Using your expression in a Stringsearcher u could have aquired your attributes bij exposing 4 elements.

 

 

If the parts would contain spaces, then it wont do of course.

 

 

Writing TLC code in the attributecreator or tester or whatever, is by far more powerfull btw.

 

Like in your case:

 

@Evaluate([regexp  {^([0-9]{1,2})\\s([A-Z0-9]{2,3}-[A-Z0-9]{2,3})\\s([A-Z]{2,3})\\s([A-Z]-[0-9]{2,3})} "@Value(Acad_lyr)" Matched Att1 Att2 Att3 Att4])?"[set Acad_lyrList [list $Att1 $Att2 $Att3 $Att4]]":"no such thing"

 

 

..makes a list in an attribute (when used in the attributecreator)

 

 

 


webservicessia
Contributor
Forum|alt.badge.img+1

I have an issue with separator like "\\\\". I counterpast it by replacing "\\\\" with a double hashtag before Splitter.


takashi
Influencer
  • January 19, 2018
webservicessia wrote:

I have an issue with separator like "\\". I counterpast it by replacing "\\" with a double hashtag before Splitter.

Hi @webservicessia, I was able to split this string

 

aaa\\bbb\\ccc
by the AttributeSplitter with these parameters.

 

Delimiter or Format String: \\
List Name: _list
Log:

 

Attribute(encoded: utf-8): `_list{0}' has value `aaa'
Attribute(encoded: utf-8): `_list{1}' has value `bbb'
Attribute(encoded: utf-8): `_list{2}' has value `ccc'
What is your problem?

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • January 19, 2018

mikesando

Rubular shows the resulting matches and submatches.

You can use the regexp you posted in a stringsearcher to achieve the same result.

Use allmatch and submatch (advanced part).

Then you captures are in the submatch list.

(also remember that Rubular can use 3 flavors. FME can not fully match what Rubular does. But mostly when the regexp gets complicated.)

Also

^(\\d+)\\s([\\w\\d-]+)\\s(\\w+)\\s([\\w\\d-]+) seems more elegant..though , as @takashi pointed out, the most discerning bit of the pattern are the spaces. You might as well do

(.+)\\s(.+)\\s(.+)\\s(.+) to get em in 4 capture groups.

Which shows you are splitting by space.

Splitter should work indeed, also pointed out by @takashi


webservicessia
Contributor
Forum|alt.badge.img+1

That work effectively. I donot know why I did not manage to do this before. Thank you for your reply.


webservicessia
Contributor
Forum|alt.badge.img+1
webservicessia wrote:

I have an issue with separator like "\\\\". I counterpast it by replacing "\\\\" with a double hashtag before Splitter.

That work now. I do not know why that was wrong before. Thank you for your answer.

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