• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 452
  • Last Modified:

Not Allowing Specific Character in Regular Expression

Is it possible to specify that you don't want a specific character at a specific position in a regular expression?

In otherwords I want it to return true if the string is "blahblahblah" but not if it is blahblahblah[" and only that one character should be disallowed.
0
jfredrickson
Asked:
jfredrickson
  • 2
  • 2
1 Solution
 
amit_gCommented:
/blahblahblah[^[]/

[^abcd] matches anything but abcd.
0
 
jfredricksonAuthor Commented:
Is there no way to only specify that you don't want that specific character?
0
 
jfredricksonAuthor Commented:
Doh! Misread that. Looks perfect, thanks.
0
 
amit_gCommented:
Thats exactly what it is. [^[] would match any character but [ i.e. the reg ex would not match if there is a [ in it (in turn disallowing it).
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now