Hi all,
Wonder if anyone can help, I have a text string P88228#UK-ORG#10R1 that I want to extract from two pieces of data.
1. All the data in front of the # (po number)
2. The line number which is after the second # but only upto and not including the 'R'
Any help would be appreciated.
Thanks
Solved! Go to Solution.
Hey @Q_Ball! I would recommend using a Formula tool. I would first create a new field for po number with this expression:
REGEX_Replace([Field1], "(.*?)\#.*", "$1")
This will extract P88228.
Then, I would create a second field for your line number with this expression:
REGEX_Replace([Field1], ".*\#(.*)R.*", "$1")
You will get you 10. This assumes that you will always want the cut off for the line number to occur after the last hashtag and before the R. Hope this helps!
Hi @Q_Ball,
Here is one formula that gives you a delimited answer. These parts can easily be parsed into separate fields.
Regex_REPLACE([Field],"^(.*?)#.*#(\d+)R.*",'$1|$2')
It will find:
^ Beginning of field
.*? Anything up to the first # symbol
(\d+) Whatever numbers are between the # symbol and the R
Groups found are the stuff between the parens....
Cheers,
Mark
This might be a little low tech, but I would just use 2 Text to Columns tools. one with # as the delimiter with 3 output columns. Using the second on the column with 10R1 in it with R as the delimiter. Unless that letter changes... In which case you could use a regex tool set to parse. Ex attached.
Best,
MSalvage
@Q_Ball Could you provide the original string that you used the formula on to get that result? I assume it is different than the one you provided initially as that one does not have "EVN-O" in it at all.
@BarnesK
My fault as sometimes there isn't an R in the data and it just has the order line number ... see example P50208#EVN-ORG#10
Is there a way of getting the line in both scenarios?
@Q_Ball Try this instead of the other formula for the line number:
REGEX_Replace([Field1], ".*\#(\d+).*", "$1")
It works for me for the two examples you have provided.
@BarnesK
Works perfectly .. thanks for taking the time out to help me.
Q