Return simply whether the string matches the pattern at all. : Match « Regular Expressions « Flash / Flex / ActionScript






Return simply whether the string matches the pattern at all.

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        var phoneNumberPattern:RegExp = /\d\d\d-\d\d\d-\d\d\d\d/;
        trace(phoneNumberPattern.test("347-222-2225")); //true
        trace(phoneNumberPattern.test("Call 800-123-4567 now!")); //true
        trace(phoneNumberPattern.test("Call now!")); //false

    }
  }
}

        








Related examples in the same category

1.Create a pattern to match against a string
2.Trace the index
3.Create a global regex to match multiple times in a string
4.Create a regular expression that matches three-letter words
5.Looking for Pattern Matches
6.Create a global regular expression that matches three-letter words
7.Force the last index to be past the first matching position
8.Creating a Nongreedy Pattern