I have an input string of the format abc;def;ghi;jkl;........ and so on. the smallest allowed input string is abc, while there is no limit on max number of tokens. Also the length of each token is NOT fixed to 3. it can be any number of characters.
for eg, america;russia;uae is also an accepted input
I want to take out the first three tokens and make separate properties out of them. In case there are less than 3, then those respective tokens should be NULL.
So far I have tried a lot of regular expressions (which I am not comfortable with)
${testprop} contains the input string.
i am using the following command
propertyregex property="testprop1" input="${testprop}" regexp="(.*)(\;.*)*/" select="\1"
but it is not working. any suggestions for a better regex !!
Thanks everyone. I finally worked out the answer.
Using the following regex,
([^;]+)([;]?[^;]*)([;]?)([;]?[^;]*)([;]?)we can get the first 3 string tokens in groups
1,2and4respectively. But the group2comes with a preceding;which can be further removed by applying\;(.*)and extracting group1.property name="inputString" value="russia;uae;germany;africa;"propertyregex property="string1" input="${inputString}" regexp="([^;]+)([;]?[^;]*)([;]?)([;]?[^;]*)([;]?)" select="\1"propertyregex property="string2" input="${inputString}" regexp="([^;]+)([;]?[^;]*)([;]?)([;]?[^;]*)([;]?)" select="\2"propertyregex property="string3" input="${string2}" regexp="\;(.*)" select="\1"propertyregex property="string4" input="${inputString}" regexp="([^;]+)([;]?[^;]*)([;]?)([;]?[^;]*)([;]?)" select="\4"This gives you the desired first three tokens in string1, string3 and string4
string1 = russiastring3 = uaestring4 = germany