Skip to main content
Question

How could I extract string text before unknown digit numbers from column


gogopotter90
Contributor
Forum|alt.badge.img+13

How could I extract only the string text before unknown digit numbers in specific column .

but if the string start with digit numbers so keep the beginning numbers and remove other digit number at this value .

 

or other method :

i would like to remove any numbers at specific column and any letters and characters come after it .

if the string start with digit numbers so keep the beginning numbers and remove other digit numbers at this column .

 

my column includes :

hghkdkfke 24a

jdklfllfv 22-23

45jdkdkkf 22 ( djskkr)

 

Target

hghkdkfke

jdklfllfv

45jdkdkkf

 

FME 2021

Thanks in advance

9 replies

dustin
Influencer
Forum|alt.badge.img+30
  • Influencer
  • January 9, 2023

Is there always only one space between the text you want and the number you want to exclude? If so, you can use the AttributeSplitter with a space set as the delimiter, and your target value will be in the attribute _list{0}.

 

Alternatively, I think you could use the following regular expression in a StringSearcher and the target value would be in the attribute _first_match.

[A-Za-z0-9]+

image


ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • January 9, 2023

You could use a StringSearcher with regular expression

^\d?[a-zA-Z\s]+

This matches 0 or more numeric characters at the start of a string, followed by one or more letters or spaces

 

Or the same regular expression in an AttributeCreator/AttributeManager

@SubstringRegularExpression(@Value(Input),^\d?[a-zA-Z\s]+,0,0,0,caseSensitive=TRUE)

 


gogopotter90
Contributor
Forum|alt.badge.img+13
  • Author
  • Contributor
  • January 9, 2023
dustin wrote:

Is there always only one space between the text you want and the number you want to exclude? If so, you can use the AttributeSplitter with a space set as the delimiter, and your target value will be in the attribute _list{0}.

 

Alternatively, I think you could use the following regular expression in a StringSearcher and the target value would be in the attribute _first_match.

[A-Za-z0-9]+

image

Thanks a lot .it looks great but I have still question .

i have found that I have 

string : fodjk jdjdk hdkld 24 a

so I need to keep  only fodjk jdjdk hdkld

but by ur method , it keeps only the first word and delete everything after it .

 

so at this case also ,what should I do 


gogopotter90
Contributor
Forum|alt.badge.img+13
  • Author
  • Contributor
  • January 9, 2023
ebygomm wrote:

You could use a StringSearcher with regular expression

^\d?[a-zA-Z\s]+

This matches 0 or more numeric characters at the start of a string, followed by one or more letters or spaces

 

Or the same regular expression in an AttributeCreator/AttributeManager

@SubstringRegularExpression(@Value(Input),^\d?[a-zA-Z\s]+,0,0,0,caseSensitive=TRUE)

 

Thanks a lot 


ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • January 10, 2023
gogopotter90 wrote:

Thanks a lot

I've amended the regex to allow for the case where you want to match spaces up until the occurence of a number not at the beginning of the string


gogopotter90
Contributor
Forum|alt.badge.img+13
  • Author
  • Contributor
  • January 10, 2023
gogopotter90 wrote:

Thanks a lot

thanks it helps but I want to do also ,

in case string like Milano street 24 close kal-3

so I would like to use search string to remove all string text before digit numbers .

I mean . to keep 24 close kal-3

so to keep the string start from digit numbers and any letter or number or special charter after it .

thanks for help .

 


ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • January 10, 2023
gogopotter90 wrote:

Thanks a lot

If you just want to keep text starting from a number (but excluding any number that is at the beginning of the string) you could search for all groups of numbers, and then use the list information with the start index of those numbers to get a substring of the original text

imageimage


gogopotter90
Contributor
Forum|alt.badge.img+13
  • Author
  • Contributor
  • January 10, 2023
gogopotter90 wrote:

Thanks a lot

Thanks a lot ,it works great


gogopotter90
Contributor
Forum|alt.badge.img+13
  • Author
  • Contributor
  • January 10, 2023
gogopotter90 wrote:

Thanks a lot

I have faced new problem ,

when I have some Adresse 34a or 4b

and other 56 d

I mean , I would like to get which string that numbers and digit together without space as 34a or 4b then i want to insert a space and it will be 34 a

and other string should 4 b


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