22401

Regex for rejecting specified strings

Question:

I have to use asp.net RegularexpressionValidator to validate input from textbox. I want to reject strings that start with "My Links" or "My Urls" I have used this

^(?!My Links|My Urls)$

but this rejects everything. How should I write this?

Answer1:

If your goal is to reject all strings that start with My Links or My Urls, then you can use lookaheads, but only if you remove the $ at the end, or only the empty string will match:

^(?!My Links|My Urls)

works as expected.

Recommend

  • Edit/Change 300 Multiple Choices on Server
  • Configure SwiftMailer “Local Domain” setting easily, in Symfony 2
  • Getting the result of the promise returned by an asyncValidator
  • TextPad “find in files” not matching on simple OR regex
  • How can I get a specific version of a dataset row?
  • Microsoft Chart Controls for Microsoft .NET Framework 4.0
  • Is mp4 stream able with ffserver?
  • How to save dynamically created textboxes and their values
  • Python/Javascript: WYSIWYG html editor - Handle large documents fast and/or design theory
  • IE10 strips out hashtag from the URL
  • several dataProvider per one Test in TestNG
  • C# List of Panels
  • How to specify input and output paths from cmd.exe for a PowerShell script?
  • How to return DataSet (xsd) in WCF
  • How to add a focus style to an editable ComboBox in WPF
  • What does 'Language neutral' mean with regard to MAKELANGID?
  • Excel's Macro-Recorder usage
  • How to handle images sent by a mobile device?
  • java inputstream
  • chrome.tabs.executeScript only fires when the Developer Console is open
  • How to render a blob on a canvas element?
  • Custom validator control occupying space even though display set to dynamic
  • How to use an array of arrays with array_map(…) in PHP?
  • FFmpeg Conversion Error
  • Email format validation in mvc3 view
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • Get object from AWS S3 as a stream
  • Cross-Platform Protobuf Serialization
  • javascript inside java/jsp code
  • Validaiting emails with Net.Mail MailAddress
  • When should I choose bucket sort over other sorting algorithms?
  • what is the difference between the asp.net mvc application and asp.net web application
  • Do I've to free mysql result after storing it?
  • Matrix multiplication with MKL
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • json Serialization in asp
  • python regex in pyparsing
  • Android Google Maps API OnLocationChanged only called once
  • Binding checkboxes to object values in AngularJs
  • How can I use threading to 'tick' a timer to be accessed by other threads?