Regular expression

Hi,

In the below paragraph how do i get the lines between "((" and "))"

my result is

Reporting by Rebecca Harrison, editing by Greg Mahlich;
Johannesburg newsroom +27 11 775 3159;
rebecca.harrison@reuters.com

can anyone give the regex to obtaining this

input is

MultiChoice said it welcomed competition, which would ensure
more choice and programme diversity.
"It will be good for the pay-TV industry ... and attract the
necessary investment into the broadcasting industry and the
South African economy," Chief Executive Nolo Letele said in a
statement.
Shares in Naspers were up 0.87 percent at 127.60 rand at
1402 GMT, when the top-40 index of blue-chip stocks <.JTOPI> was
up 0.94 percent.
((Reporting by Rebecca Harrison, editing by Greg Mahlich;
Johannesburg newsroom +27 11 775 3159;
rebecca.harrison@reuters.com))
($1=6.011 Rand)
($1=.5613 Pound)

Thanks

Radhakrishnan.K



Answer this question

Regular expression

  • Joe Clifford

    Hi,

    Yes the regex

    \(\((\w* \W* )* \)\)

    is working in regex tester

    http://regexlib.com/RETester.aspx

    once i apply this in my code it is showing "index was out side the bounds of the array error"

    any suggestions

    My code

    string strInput = TxtInputString.Text; //<- input

    string strRegEx = TxtRegex.Text; //<- RegeX

    Regex DateLineRE = new Regex(strRegEx,RegexOptions.Multiline);

    MatchCollection matches = DateLineRE.Matches(strInput);

    foreach(Match match in matches)

    {

    MessageBox.Show(match.Value);

    }

    Thanks in advance

    Radhakrishnan.k


  • Jonathan van de Veen

    Hi, thanks again,

    The regex (\((\w* \W* )* \)\)) is working

    string strInput = TxtInputString.Text; //input Text

    //TxtRegex.text - input regular expression

    Regex DateLineRE = new Regex(TxtRegex.Text,RegexOptions.IgnoreCase | RegexOptions.Multiline);

    MatchCollection matches = DateLineRE.Matches(strInput);

    foreach(Match match in matches)

    {

    MessageBox.Show(match.Value);

    }

    }

    once i apply the (\((\w* \W* )* \)\) here, showing error

    An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.dll

    Additional information: Index was outside the bounds of the array.

    Can you modify the above code to get the proper output

    I hope you'll solve

    Thanks

    Radhakrishnan.K


  • J. Leite

    hey man,

    \(\((\w* \W* )* \)\)

    That seemed to do the trick.



  • Robert Taylor

    It should be

    (\\((\\w* \\W* )* \\)\\))

    because "\" backslash is an escape sequence so you have to put extra "\"

    Whenever you want to use one of these special characters you need to use a technique known as escaping the character. Escaping the character means typing a backslash (\) in front of the character
    from http://www.peachpit.com/articles/article.asp p=31938&seqNum=9


  • Regular expression