I have string like this which looks like a url
mainpath/path2/abc/PI 6/j
From the string I need to get the number along with PI
Main problem is the position of PI part wont be always the same. Sometimes it could be at the end. Sometimes at the middle.
So how can I get that number extracted using regex? I'm really stucked with this
22 Answers
It's as simple as using the RegEx Tool. A Regular Expression of /PI (\d+)
and the Output Method of "Parse" should do the trick.
If you're using Alteryx... suppose your field name is [s]
and you're looking for [f]
(in your example the value of [f]
is "PI")... then you could have a Formula tool that first finds /PI
by first creating a new field [tmp]
as:
SubString([s],FindString([s],"/"+[f])+1)
and then creating the field you're after [target]
:
SubString([tmp],0,FindString([tmp],"/"))
From there run [target]
through a "Text to Columns" tool to split on the space, which will give you "PI" and "6".
ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobHFqY2p%2BeHyOq5ygnahisrnA0ZqarWWeqrqjsdFmnaunnWKubr%2FTq6Cnn12strW0jJpkrKiVmLantcJmp5qspJq%2Fr3nIp2SapKSav7rE