Question

regexp in stringsearcher

  • 6 February 2014
  • 4 replies
  • 7 views

Badge +3
Hi all,

 

 

 

I have a question conserning regular expressions in the stringsearcher/replacer  transformers.

 

 

When i ue a attributecreator or eqquivalent and enter

 

[regexp {.*:\\s*([\\w\\s\\W]*) } "@Value(Someattribute)"]

 

then

 

OTD Open verharding: gebakken klinkers

 

will yield

 

gebakken klinkers

 

(i have to extract this match of course, but thats not the issue here..)

 

 

Using this same regexp in a stringsearcher or equivalent will not give a match.

 

 

Why is this.

 

 

Don't they use the same tcl?

 

 

 

Greetings

 

Gio

4 replies

Userlevel 2
Badge +17
Hi Gio,

 

 

In my Japanese environment, shorthand classes \\w and \\W cannot be used (I don't know why). But I think your regular expression is equivalent to this:

 

.*:\\s*(.*)

 

 

And the StringSearcher with the expression was able to extract words after the colon correctly. i.e. _matched_parts{0} = "gebakken klinkers"

 

How did your StringSearcher work?

 

 

Takashi
Badge +3
Hi Takashi,

 

 

 

I spent some time on the the tcl site:

 

 

"Within bracket expressions, `\\d', `\\s', and `\\w' lose their outer brackets, and `\\D', `\\S', and `\\W' are illegal"

 

 

.*:\\s*([\\w\\s]*\\W*) works. I just had to take the \\W out of the brackets.

 

of course that will only get sequences up to a nonword character, dissalowing me to enter nonwordcharacter in a character class (range).

 

 

I now use

 

 

value:

 

@Evaluate([regexp {.*:s*([[:alpha:]\\s-]*)} "@Value(CLASSIFICATIE)" matched match])!=0?"$match":""

 

 

This way i dont have to use te stringsearcher, expose and and setattribute routine at all.

 

 

 

 

regexp .*:\\s*(.*) is the same, but i wanted .*:s*([[:alpha:]\\s-]*)

 

i mistook \\w for [:alpha:]

 

Apparently there is no shorthand for [:alpha:]

 

 

 

 

a tip for the fme boys.

 

How about not having the creator automaticaly put an evaluation on stuff one enters.

 

Like when i enter a concatanation in creator this way @Value(sting1)@Value(string2)..it automatticaly tries to evaluate it....

 

Even changing an attribute causes it to put an evaluation on it, can this be turned of?

 

very annoying. Im forced to go back and remove the evaluation.
Userlevel 2
Badge +17
"[:alpha:]" is equivalent to a frequently used character class "a-zA-Z"?

 

 

-----

 

 

If you entered "@Value(string1)@Value(string2)" using the Arithmetic Editor, indeed "@Evaluate" would be appended automatically.

 

Otherwise (using the Text Editor - Base / Advanced or typing directly), I don't think it would be evaluated.
Badge +3
Yes character class [a-zA-Z] is the same as the bracketclass [:alpha:]

 

But there is no shorthand for it. Shorthand is like \\w  which is same as bracket [:alphanum:] including "_".

Reply