locked
Regex pour matcher "abc.bcd.efgh.FinalString" RRS feed

  • Question

  • User-1668256174 posted

    Hello everybody,

    I am looking for a regex which matches strings like :

    "aaa.bcd.efgh.FinalString"

    where 'FinalString' is a constant string and 'aaa.bcd.efgh.' is a variable strings sequence, each string is composed by any characters except space and must end with a '.' .

    using System.Text.RegularExpressions;

    ...

    string sPatternDataTable = @"([^\s]\.)*FinalString"; Regex regexObj; regexObj = new Regex(sPatternDataTable, RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline); string sContent = "abc.bcd.efgh.FinalString"; Match match = regexObj.Match(sContent); if (match.Success) { string sProc = "Success"; }

    But this regex doesn't work.

    match.Success returns false.

    Thank you very much in advance.

    Eric.

    Saturday, August 20, 2016 9:05 PM

Answers

  • User-1668256174 posted

    In fact, I found what I needed.

    I use now this regex :

    ([^\s]+\.)*FinalString

    Eric

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 21, 2016 8:58 PM