How do I match an entire string with a regex?

前端 未结 7 1300
渐次进展
渐次进展 2020-11-22 00:15

I need a regex that will only find matches where the entire string matches my query.

For instance if I do a search for movies with the name \"Red October\" I only wa

7条回答
  •  日久生厌
    2020-11-22 00:31

    Sorry, but that's a little unclear.

    From what i read, you want to do simple string compare. You don't need regex for that.

    string myTest = "Red October";
    bool isMatch = (myTest.ToLower() == "Red October".ToLower());
    Console.WriteLine(isMatch);
    isMatch = (myTest.ToLower() == "The Hunt for Red October".ToLower());
    

提交回复
热议问题