Avatar of Rodrigo Costa
Rodrigo Costa
Flag 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!
PHPAJAXJavaScript

Avatar of undefined
Last Comment
Jon Norman

8/22/2022 - Mon
Jon Norman

in javascript:

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

Open in new window


where variableName is the variable.
ASKER CERTIFIED SOLUTION
Jon Norman

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy