Skip to main content

I am trying to split an attribute using a regular expression as there may be differences within the attribute.

 

For Example the attribute may be as AA9A or B7B

However some of the attributes are formatted as CC7 or DD6 I therefore do not want to remove the last character from these, all I need to extract is AA9 or B7.

 

Is there a way with a regular expression to search for a character, potential character and then a digit?

Or is there a better way to achieve what i am trying to do??

Thanks in advance

Andy

 

There could be a simple solution but I go with StringSearcher with regex ^[A-Z]*[0-9]* or something like that.

Then you could replace the found string with the original if you want an attribute with just the A and the B in an AttributeCreator.


In the StringReplacer you can use the regular expression 

\D$

(all characters at the end of the attribute that are not numbers), and replace this with nothing.

 


I'd use the string searcher with the following REGEX

(>a-zA-Z]{1,2}\d)

/a-zA-Z]{1,2} matches one or two characters (A-Z case insensitive)

\d matches one digit

(...) groups everything together

 

https://rubular.com/r/h9ItOkxPbyldAZ


Reply