Skip to main content
Solved

How to find string that start with one letter then numbers

  • May 15, 2023
  • 1 reply
  • 1260 views

spiderman
Contributor
Forum|alt.badge.img+7

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

 

Best answer by ebygomm

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]_.*

 

 

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

1 reply

ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • Best Answer
  • May 15, 2023

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]_.*