Flagrant Badassery

A JavaScript and regular expression centric blog

RegexPal: Web-Based Regex Testing Reinvented

Yes I know, there are many other JavaScript regex testers available. Why did I create yet another? RegexPal brings several new things to the table for such web-based apps, and in my (biased) opinion it's easier to use and more helpful towards learning regular expressions than the others currently available. Additionally, most other such tools are very slow for the kind of data I often work with. They might appear fast when displaying 10 matches, but what about 100, 1000, or 5000? Try generating 5,000 matches (which is easy to do with an any-character pattern such as a dot) in your favorite existing web-based tool and see if your browser ever recovers (doubtful). The same task takes RegexPal less than half a second, and what's more, results overlay the text while you're typing it.

At the moment, RegexPal is short on features, but here are the highlights:

  • Real-time regex syntax highlighting with backwards and forwards context awareness.
  • Lightning-fast match highlighting with alternating styles.
  • Inverted matches (match any text not matched by the regex).
regexpal.com screenshot

I'm not sure when I'll add additional features, but there are lots of things I'm considering. If there is something you'd like to see, let me know.

A few things to be aware of:

  • The approach I've used for scrollable rich-text editing (which I haven't seen elsewhere) is fast but a bit buggy. Firefox 2 and IE7 have the least issues, but it more or less works in other browsers as well.
  • The syntax highlighting generally marks corner-case issues that create cross-browser inconsistencies as errors even if they are the result of browser bugs or missing behavior documentation in ECMA-262 v3.
  • There are different forms of line breaks cross-platform/browser. E.g., Firefox uses \n even on Windows where nearly all programs use \r\n. This can affect the results of certain regexes.

At least for me, RegexPal is lots of fun to play with and helps to make learning regular expressions easy through its instant feedback. I encourage you to just go play with it and discover its results on your own, but for the curious, I'll keep rambling…

Regex syntax parsing (needed for the syntax highlighting) is somewhat complex, due to the numerous backwards and forwards context awareness issues involved. Take, for example, the pattern \10. What does it mean?

  • Backreference 10, if not inside a character class and at least 10 capturing groups are opened before that point.
  • Backreference 1, followed by a literal "0", if not inside a character class and between 1 and 9 capturing groups are opened before that point.
  • Octal character index 10 (decimal 8), if inside a character class, or if no capturing groups are opened before that point.
  • The three literal characters "\", "1", and "0", if preceded by an unescaped "\" character.
  • An incomplete token in a couple other situations.

Another example is the "-" character. Outside a character class it's always a literal hyphen, but inside a character class…

  • It creates a range between tokens if:
    • There is a preceding and following token in the class, or it's preceded by a token and is the last character in an unclosed character class (caveats follow).
  • It's a literal character if:
    • It's the first or last character in the class.
    • It's preceded by an unescaped "\".
    • It follows a token which is the end index for a range.
    • It follows a hyphen which creates a range.
  • It's an error if:
    • It's creating a range between tokens in reverse character index order (e.g., z-a, @-!, \uFFFF-\b, or \127-\cB).
    • It would otherwise create a range, but it's followed or preceded by a token which represents more than one character index (e.g., \d). In fact, in some cases browsers take this to mean that the hyphen should be treated as a literal, but browser bugs cause it to be handled inconsistently so RegexPal flags it as a range error.

Here are a few more things which aren't errors but are flagged as such:

  • Empty, top-level alternation, except at the end of the pattern, where such an alternation is ignored when highlighting matches in order to create a less surprising experience while the user is in the middle of constructing the regex. Empty, top-level alternation is flagged as an error because it effectively truncates the regex at that point (since it will always match). If a zero-length, top-level alteration is really needed, there are other easy ways to do that more explicitly.
  • Lookaround quantifiers (e.g., the plus sign in (?!x)+). This would be an actual error with some regex libraries (e.g., PCRE), and although that's not the case in most web browsers, such constructs add no value. As a result, RegexPal flags such quantifiers as an error, since they are almost certainly a user mistake.
  • \c when not followed by A–Z, \x when not followed by two hex characters, and \u when not followed by four hex characters. Although these do not cause most browsers to throw errors, they are handled inconsistently cross-browser and are hence flagged as errors. They would almost certainly be a user mistake even if the cross-browser issues didn't exist.

Credit to osteele.com from where the text of the short-and-sweet Quick Reference is based, and to RegexBuddy from JGsoft for inspiring many of RegexPal's features. The name RegexPal is, in part, a nod to RegexBuddy, but also selected because it contains both "regex" and "regexp." wink

There Are 162 Responses So Far. »

  1. This site truly has all of the information I wanted concerning this subject and didn’t know who to ask.

  2. You need to be a part of a contest for one of the most useful blogs online. I’m going to highly recommend this website!

  3. This site really has all the information I wanted about this subject and didn’t know who to ask.

  4. This site really has all the information I wanted about this subject visit us https://britishshorthair.company.com

  5. VISIT US https://bengals.company.com

  6. We are happy to announce the arrival of this beautiful litter of Bengal kittens, Serval kittens, savannah kittens and Caraca kittens

    Both parents can be seen and are TICA registered. Parents are both tested positvely for all health issues
    Both male and Female available in these litters.

    Kittens are all health tested positively and will be TICA registered pets only

    All kittens will be weaned onto Royal Canin Kitten wet and dry food and will be litter trained by the time they leave us.

    These adorable little monkeys are being brought up in a clean, warm and loving environment, as well as a very busy household with other dogs, cats and young children so will be well socialised, handled daily and use to noise.

    They will come with an extensive kitten pack for you to start them off in their new homes. The only thing you will really need to worry about is a carrier to take your kitten home in and getting to know your new family member.

    All kittens will be health checked thoroughly by a qualified Vet at their Veterinary Practice before they leave and will have their:
    •1st Vaccinations with Healthcard certificate (can do 2nd set just enquire)
    •Microchipping
    •4 weeks free Kitten insurance (with PetPlan) covered from the day they leave us.
    •Routine flea treatment (Frontline/ Advocate)
    •And will have been wormed up to date from 2 weeks old (Panacur paste)

    They will also come with an extensive kitten pack which will include:
    •Sales receipt
    •Diet & info sheets
    •Kitten Handbook
    •Food and water bowls
    •Bag of high quality food wet & dry
    •Feeding measuring cup
    •Feeding mat
    •Toys
    •Treats
    •Grooming brush or mit
    •Collar
    •Catsan cat litter
    •Litter tray & Poop scoop
    •Blanket with mums scent on
    •And a lifetime of support and advice.
    https://www.chatsexotiquesavendre.com/

  7. We are Munchkin kittens and cat breeder in the usa and specialized in breeding munchkin kittens and cats for sale. We have been breeding munchkin kittens for over 11 years and have much experience with this breeds of cats and kittens. https://munchkinkittens.net/

  8. munchkin kittens for sale near me,munchkin kitten price,munchkin kittens for sale in ohio,munchkin kittens for sale texas,munchkin kittens for sale nc,munchkin kittens for sale in iowa,munchkin kittens for sale in pa,munchkin kitten breeders,munchkin kitten for sale,munchkin kitten pictures,munchkin kitten gif,munchkin kitten houston,munchkin kitten for sale michigan,munchkin kitten adoption,munchkin kitten alabama,munchkin kitten arkansas,munchkin kitten australia,munchkin kitten adoption singapore,munchkin kitten alberta homelandmunchkins.net

  9. Our Amazing Girl Lolo Has Had Amazing Litter Of Beautiful Pug’s Which Are Definitely Amazing She Had Females & Males Puppies Are Doing Amazingly Well. Puppies are ready to leave. They Have had thier First Injections /Mirco-Chipped/Vet Checked,Wormed & Fled To Date.
    Puppy’s will also have a puppy pack including blanket with mum scent,toy,food,puppy pads also a information pack on future care.

    Visit our website for more: https://uptownpugs.com

  10. british shorthair kittens for sale,
    british shorthair kittens for sale near me,
    british shorthair kittens for sale price, british shorthair kittens for sale in florida,
    british shorthair cinnamon kittens for sale,
    british shorthair kittens for sale texas,
    british shorthair kittens for sale california,
    british shorthair kittens for sale ohio, white british shorthair kittens for sale,
    british shorthair kittens for sale in pa,
    blue british shorthair kittens for sale, british shorthair kittens for sale illinois,
    cinnamon british shorthair kittens for sale,
    british shorthair kittens for sale ny, british shorthair kittens for sale in michigan,
    british blue shorthair kittens for sale,
    british shorthair kittens for sale los angeles,
    british shorthair chinchilla kittens for sale,
    british shorthair kittens for sale in usa, british shorthair kittens for sale oregon,
    british shorthair kittens for sale nyc,
    silver tabby british shorthair kittens for sale,
    lilac british shorthair kittens for sale,
    british shorthair kittens for sale georgia,
    chocolate british shorthair kittens for sale,
    british shorthair silver tabby kittens for sale,
    golden british shorthair kittens for sale, british shorthair kittens for sale in pakistan,
    british shorthair kittens for sale massachusetts, british shorthair scottish fold kittens for sale,
    https://kittenbreeders.company.com

  11. Cockatoos For Sale
    And Gold Macaws For Sale,African Grey Parrots For Sale,Hyacinth Macaws For Sale,Green Wing Macaws For Sale,Scarlet Macaws For Sale,Toucans For Sale.
    Visit our website : http://cockatoo.company.com
    Text 347-667-5561
    Thank You.

  12. Cornish rex kittens for sale,
    Cornish rex kittens for sale near me,
    Cornish rex kittens for sale price, Cornish rex kittens for sale in florida,
    Cornish rex cinnamon kittens for sale,
    Cornish rex kittens for sale texas,

    http://www.kittencattery.company.com

    Cornish rex kittens for sale california,
    Cornish rex kittens for sale ohio, white Cornish rex kittens for sale,
    Cornish rex kittens for sale in pa,
    blue Cornish rex kittens for sale, Cornish rex kittens for sale illinois,
    cinnamon Cornish rex kittens for sale,
    Cornish rex kittens for sale ny, Cornish rex kittens for sale in michigan,
    british blue shorthair kittens for sale,
    Cornish rex kittens for sale los angeles,
    Cornish rex chinchilla kittens for sale,
    Cornish rex kittens for sale in usa, Cornish rex kittens for sale oregon,
    Cornish rex kittens for sale nyc,
    silver tabby Cornish rex kittens for sale,
    lilac Cornish rex kittens for sale,
    Cornish rex kittens for sale georgia,
    chocolate Cornish rex kittens for sale,
    Cornish rex silver tabby kittens for sale,
    golden Cornish rex kittens for sale, Cornish rex kittens for sale in pakistan,
    Cornish rex kittens for sale massachusetts, Cornish rex scottish fold kittens for sale,

Post a Response

If you are about to post code, please escape your HTML entities (&, >, <).