Question

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

  • 9 January 2023
  • 9 replies
  • 65 views

Badge +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

Userlevel 3
Badge +26

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

Userlevel 1
Badge +21

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)

 

Badge +13

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 

Badge +13

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 

Userlevel 1
Badge +21

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

Badge +13

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 .

 

Userlevel 1
Badge +21

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

Badge +13

Thanks a lot

Thanks a lot ,it works great

Badge +13

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

Reply