I have .NET regular expression <asp:textbox\b((?!maxlength).)*> that matches text "<asp:textbox" not followed by "maxlength". I want to port this regular expression to MINGW. I'm fine with grep or whatever tool.

I managed to figure out \<asp:TextBox\\b. The one slash before < and two slashes before b already confused me, and I have no luck putting ((?!maxlength).)*> back.

Can anyone help me?

enter image description here

  • for lookarounds, you need grep -P if it is supported in your setup... would suggest that you post sample text input and show which lines you need and which lines shouldn't be part of output... also, you should quote your regex inside single quotes to avoid shell interpretations – Sundeep Oct 7 '17 at 4:08

Just you need to add -P option of grep if you have it.

grep -P '\<asp:textbox\\b\((?!maxlength).*\>'

Also here not necessary you use negative-look-ahead assertion, and if your grep doesn't have/support -P option, use grep with reverse switch grep -v.

grep -v '\<asp:textbox\\b(maxlength.*\>'
  • to OP: also not sure if \b is actual characters in your input or it's word boundaries \bword\b! I assumed it's actual \b – αғsнιη Oct 7 '17 at 6:17
  • I want \b for word boundary. – Gqqnbig Oct 8 '17 at 18:35
  • do \bword\b or \<word\> or use -w option of grep then. – αғsнιη Oct 8 '17 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.