Solved

How to find string that start with one letter then numbers

  • 15 May 2023
  • 1 reply
  • 34 views

Badge +3

Hello ,

i would like to use Regex to find three cases :

1.the string that starts with one letter then numbers as example a73939 or s939

2.and also to find string like S2820_hjd

(one letter then few numbers then underscore then numbers or letters )

3.and any string that start with one letter then underscore as O_Sjdld

i tried using string searcher transformer but I am not sure which regex should I type ?

fme 2021

thanks for help

 

icon

Best answer by ebygomm 15 May 2023, 19:47

View original

1 reply

Userlevel 1
Badge +10

So a string starting with a letter followed by one or more numbers

^[a-zA-Z][0-9].*

^ start of line

[a-zA-Z] matches a single character

[0-9] matches a single number

.* matches any character an unlimited number of times

 

A string that starts with one letter then an underscore

^[a-zA-Z]_.*

^ start of line

[a-zA-Z] matches a single character

_ matches an underscore

.* matches any character an unlimited number of times

 

You can put them together separated by a pipe in the StringSearcher so anything that matches one or the other will exit the Matched port

e.g.

^[a-zA-Z][0-9]{2}.*|^[a-zA-Z]_.*

 

 

 

Reply