Need help on RegEx

0 views
Skip to first unread message

MIMI

unread,
Aug 20, 2009, 4:00:47 PM8/20/09
to Regex
I'm very new to RegEx. Please help me to solve my problem. I've couple
of similar types of strings.
for example:

Example string1: A. How To Refer the Manual (Refer image 1)

or

Example string2: B. This is the solution (Refer image 2)

What should be my regular expression so the match value will be A.
How To Refer the Manual in case of string1. and B. This is the
solution in case of string2 ?

Patrick Kennedy

unread,
Aug 21, 2009, 10:33:10 PM8/21/09
to re...@googlegroups.com
My approach would be to use regex to sanitize the input to ensure that
the pattern or characters are permissible. If the regex string passes
the test, your application can then test the string to see if it
equals an exacts string value.

The regex here would test for a string that must only contain
characters, numbers, a period, and ( ). If true, then the app can
proceed to test an exact string value of: "A. How To Refer the Manual
(Refer image 1)". Much easy to do it this way.

Maybe others can help you with the exact regex to test for the "safe"
characters you require - I'm still not that adept in it - but there
are regex Apps that can help you build such regex test.

~Patrick

one tmjd

unread,
Aug 21, 2009, 9:51:43 PM8/21/09
to re...@googlegroups.com
this is perl code , I don't know if it can work
if(/^Example string(\d):\s+([^\(]+)/
{
        if($1 eq "1")
        {
           .....#captured is stored in $2
        }
        if($1 eq "2")
       {
        .....
       }
}

2009/8/21 MIMI <princes...@gmail.com>
Reply all
Reply to author
Forward
0 new messages