Regex, look for Uppercase code but don't include numbers that start with dollar signs

regex match uppercase words
regex tester
regex uppercase first letter
regex upper or lowercase word
java regex uppercase
regex capital letters only
javascript regex
regex lowercase followed by uppercase

I have strings that look similar to this...

If you want to shop in store, use this coupon ZXXZX123 to save $20 off your in-store purchase of $100 or more, or $100 off $500 or more."

In the end all i want is ZXXZX123

I have started off with this that looks for Uppercase and numbers and must be at least 2 characters. After that, I am not sure how to not include the others. I guess other phrases my include things like 20% off so I don't want to include those types of numbers either.


What is the Regular Expression for all UPPERCASE letters on forms , If you want the regular expression to match multiple words, you'll also I don't know if this helpful, and I can't take credit for it crating the code (I  The following code snippet uses RegexOptions.IgnoreCase parameter to make sure that Regex does not look for uppercase or lowercase. // Create a pattern for a word that starts with letter "M" string pattern = @"\b [m]\w+"; // Create a Regex

You can split the match expressions for uppercase chars and the digits, then combine with a "not $" in the middle.


Regex to test for lowercase characters, So powerful, but so tricky to learn! Recently I found myself scratching my head over how to write a regular expression to check that a string  Regex Tester isn't optimized for mobile devices yet. You can still take a look, but it might be a bit quirky. > Okay!

Simply excluding dollar sign would match other characters like white spaces for example. So this is won't work : [^\\$] [A-Z0-9]{2,}

Instead match for whitespace preceding the code but exclude it by using the capturing group: [\\s]([A-Z0-9]{2,}) and in your match or replacement reference group number 1. See

Java Check a String for Lowercase/Uppercase Letter, Special , Learn how we to check if a String contains at least one uppercase One of the ways to perform our check is by using regular expressions. Also, there would be no need to iterate over all of them and find which matches and which don't. As usual, complete source code can be found over on GitHub. The logic is similar to condition 2: we look for an optional number of non-uppercase letters, then one uppercase letter… But we need to repeat that three times, for which we'll use the quantifier {3} .

Please use this regex, this will only capture coupon codes.

Regex: '[A-Z][A-Z0-9]+'

Explanation: [A-Z]: First letter is alphabet and is UPPERCASE. [A-Z0-9]+: From second letter and onwards it will look for a combination of digits 0-9 or/and alphabet which is in UPPERCASE.

Link to Example:

Let me know if you have any question.

Everything you need to know about Regular Expressions, Whenever you want to check whether a string is a valid zip code, you can match it The following character class matches all lower case and upper case Latin characters: is used to match “anything” or “don't care” sections. 1. Line Anchors. In regex, anchors are not used to match characters.Rather they match a position i.e. before, after, or between characters. To match start and end of line, we use following anchors:

Regular expression syntax, Regular expression syntax has several basic rules and methods. In the character set, a hyphen indicates a range of characters, for example [A-Z] will match any one capital letter. which excludes the ASCII carriage return and line feed codes. reFindNoCase("\bBig\b", "Don't be ambiguous about Big. Edit: 2015-10-26: thanks for the upvotes - but take a look at tchrist's answer, especially if you develop for the web or something more "international".. Oren Trutners answer isn't quite right (see sample input of "RightHerE" which must be matched but isn't)

(Tutorial) Python Regular Expression, Discover the power of regular expressions with this tutorial. If you've ever used search engines, search and replace tools of word processors TIP: You don't actually need it for this example; however, it is a good practice to use it for consistency. However, the code below will not give the same result. The tables below are a reference to basic regex. While reading the rest of the site, when in doubt, you can always come back and look here. (It you want a bookmark, here's a direct link to the regex reference tables). I encourage you to print the tables so you have a cheat sheet on your desk for quick reference.

SPLIT STRING WHERE lowercase begins and only keep uppercase , To extract text, you can do this: Regex.Match(text, rPattern).Value.Trim There are other uppercase letters throughout that I DON'T want to match also. I really Then I imported that into my invoke code method, and I put this. Regex tutorial — A quick cheatsheet by examples The result is the same of the first regex -> Try it! Look-ahead and Look even during a code session using a common IDE to translate a Java

  • Can't you be more precise about the format of a coupon code? Does it always start with a letter or can it start with a digit? Can it be only letters? Can it be only digits? Can it be 20 characters long? The more specific you can be, the better the regex can be.
  • ZXXZX123 is the coupon code and this example won't work. As Coupon code has to be between two words. As you making boundary that word there will be space around the coupon code. So for the string I wrote above, it won't work.
  • Thanks, fixed that
  • Positive look behind, in the beginning, is not a good idea as it will miss one more scenario. Just in case, Do not take it personally just a thought.
  • Thanks for pointing this out. This text is not well formatted though - there should be a space after a dot.
  • Thank you all for your submissions. I have tried them all and they have all seem to be working for what I need. mrzasa had the first reply and I am currently using it and it's working really well. I guess with regex there is no definitive way of accomplishing a task.
  • [^\$] is not required. The Regex will work without that too. Try it out. As you are putting it at the later position in word.
  • This will also capture 'What' and 'OK'.
  • Now you have a different problem. It does not capture all of "XY02AB".
  • @tricot: With all due respect, and without any assumption, use the link I gave as an example. If it fails then please let me know. It should not and it will not with the two examples you gave me.
  • The regex in and are different. My first comment was about the first -- where "What" is indeed rejected (my mistake), but OK is not (demo:, then you posted the second, and my second comment is about that (demo:
  • 1. Data in a sentence with CamelCase. Means starts with the first word in a sentence starts with Capital rest except coupon code is lowercase. So Regex in example 1 works fine as per my understanding. 2. The second regex I created to show you, even if I remove words it will still work and then you agreed that it was your mistake. Here the assumption is that the coupon code will be UPPERCASE and it will have numbers in it.