Google
Regex

Print this page

 

 

A regular expression (regex or regexp for short) is a special text string for describing a search pattern. You can think of regular expressions as wildcards on steroids. You are probably familiar with wildcard notations such as *.txt to find all text files in a file manager. The regex equivalent is .*\.txt$.

But you can do much more with regular expressions. In a text editor like EditPad Pro or a specialized text processing tool like PowerGREP, you could use the regular expression \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b to search for an email address. Any email address, to be exact. A very similar regular expression (replace the first \b with ^ and the last one with $) can be used by a programmer to check if the user entered a properly formatted email address. In just one line of code, whether that code is written in Perl, PHP, Java, a .NET language or a multitude of other languages.

var textVal = "";
var refString = "/\:*%#@!^&<>|';$~`";
var refStr = "[/\\\\:*%#@!^&<>|';$~`]"; *
var regExp = new RegExp(refStr);
textVal = this._tfName.getText(); //getting value from a text field and setting in textVal.
textVal = textVal.trim();

if(textVal != ""){

if(regExp.test(textVal)){
this._tfName.setText("");
return;
}

}

* one of the foward slash is used to escape the back slash

On this Page
 

On InterviewFundas.com
Regex Tutorial
 

Related links to other sites

 

 
 
You can put your ad here
 
 Top  
   
   

You are visitor number :