Link to home
Start Free TrialLog in
Avatar of Rodrigo Costa
Rodrigo CostaFlag for New Zealand

asked on

Detect if certain text is in a variable

Hi folks, I need to findout if a certain text was typed in a certain variable, for example a form send to my script a variable named "URL", in this variable the user had to have typed an url for a certain file they should have in their server, what I want is a way to find out if in this variable they typed "for123" in the variable, it could be in the beggining, in the middle or at the end, but I would need to know it and I can't seem to find a way to do this...

Any help would be appreciated.

Cheers!
Avatar of Jon Norman
Jon Norman
Flag of United Kingdom of Great Britain and Northern Ireland image

in javascript:

if(variableName.match(/for123/)){
  alert("matched");
}else{
  alert("not matched");
}

Open in new window


where variableName is the variable.
ASKER CERTIFIED SOLUTION
Avatar of Jon Norman
Jon Norman
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial