Delete part of a string

After looping through a website extracting data from pages, I am given

39393AB939
(Opens in a new window)

I am trying to extract just the alphanumeric text, but cant see to get it to, I have tried string.replaceetc… “(Opens in a new window)”

Its a company reference so the format will never be fixed

should I be trying a different approach?

image

regex can help
grafik

2 Likes

apologies, im after everything apart from (“Opens new window”)

@barryrodick
see some furthe sample

If it is not matching your requirement then do following
Input:
39393AB939
(Opens in a new window)

Expected Output:
Define Sample Value

1 Like

One simple regex would be: \b\w+(?=\r|\n|$)
This finds any word 1+ characters long with a word boundary on the left side (meaning newline, whitespace, start of the string) and finds either a newline or the end of the string on the right side of those 1+ characters it found. It will find any alphanumeric characters, along with decimal points and underscores. If you only want alphanumeric then switch the \w with [A-Z,a-z,0-9] instead.

You can put this in an assign activity to return a string back like this: Assign YourString = System.Text.RegularExpressions.Regex.Match(InputString,"\b\w+(?=\r|\n|$)").Value

2 Likes