Page 1 of 1

matchText & Regex help!

Posted: Wed Dec 24, 2014 8:29 pm
by ARAS
Hello all,

I need some help. I need to get the number which is after "id_no=" in a field.

I have tried to get it with the code below but the answer box is always empty. It doesn't return the value. Is there a way to return the value that matches with regex? For example, 21234 from the link below.

Inside the field
http://www.abcdef.com/odc/eds.asp?id_no=21234

Code

Code: Select all

answer funwithRegex("id_no=[0-9]*")

Code: Select all

function funwithRegex theName
   if matchText( field "Field", theName, theValue) then
      return theValue
   else
      return "not found"
   end if
end funwithRegex
Thanks for the help.

Re: matchText & Regex help!

Posted: Fri Dec 26, 2014 1:08 am
by phaworth
You need some "capturing parentheses" in your regex. Right now the regex matches but there's nothing for it to return to you. Try:

id_no=([0-9]*)

Pete

Re: matchText & Regex help!

Posted: Fri Dec 26, 2014 7:14 pm
by ARAS
Thanks Pete! It works!