Home > How & Why, Interactive knowledge & Tips n Tricks & other reference stuff > How to test Regular expression across the programming languages?

How to test Regular expression across the programming languages?

September 29th, 2010 218 views Leave a comment Go to comments


Regular expression

Prerequisite

Regular expression, in introduction with full of example

A regular expression (regex or regexp for short) is a special text string for describing a search pattern.

There are various flavours of Regular Expressions. All the flavours are 80% common. Some languages provide more elements, functions and keywords for efficient searching. Maximum of them have common regular expression elements. You can test them in various languages as follow.

AWK

    awk ‘/RE/’ filename

JAVA

	boolean b = Pattern.matches("RE", "contents");

PHP

        preg_match_all(‘/RE/’,$contents,$result_array)

PERL
I havn’t gone through PERL syntax. But they are similar to AWK.

C# (.NET)

	Regex pattern=new Regex("RE");
        bool matching = return pattern.IsMatch("Contents");

Common elements are also supported by rich text editor programs like textpad or notepad++.

You can also try Online Tool to test for testing regular expression.

Amit Gupta

Hey! this is Amit Gupta (amty). By profession, I am a Software Eng. And teaching is my passion. Sometimes I am a teacher, as you can see many technical tutorials on my site, sometimes I am a poet, And sometime just a friend of friends...

  1. October 4th, 2010 at 00:11 | #1

    I welcome you. But i prefer to exchange links with user who has their own domain.

  2. KathrynLawrence
    October 3rd, 2010 at 22:34 | #2

    I would like to exchange links with your site article-stack.com
    Is this possible?