locked
Extract string not work in break line RRS feed

  • Question

  • User-1011572351 posted

    Hi

    I'm have my regex: 

    \{IMacro\} (.*?) \{FMacro\}

    In inline, is ok

    {IMacro} Conntent here {FMacro}

    Bus if I break line:

    {IMacro}

    Conntent

    here {FMacro}

    Not work :( 

    How ignore break line and case sensitive {IMacro} init ?

    Thursday, March 19, 2015 8:55 PM

Answers

  • User-271186128 posted

    Hi Rodrigo,

    As for this issue, you could try to use Regular Expression Options. Please refer to the following sample:

                string str = "{IMacro} Conntent \n here {FMacro}";
                TextBox2.Text = str; //Output: {IMacro} Conntent 
                                     // here {FMacro}
    
                string parent = @"\{IMacro\} (.*?) \{FMacro\}";
                MatchCollection matchs = Regex.Matches(str, parent,RegexOptions.Singleline);
                string str2 = matchs[0].Value;  //Output: {IMacro} Conntent 
                                                // here {FMacro}

    More details about Regular Expression Options, please see: https://msdn.microsoft.com/en-us/library/yd1hzczs(v=vs.110).aspx

    Best Regards,
    Dillion

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 22, 2015 10:31 PM

All replies