Showing posts with label RegEx. Show all posts
Showing posts with label RegEx. Show all posts

Monday, June 02, 2014

The ".NET Framework Regular Expressions" Cheat Sheet (1 page, front and back, lots-O-info)

Microsoft Downloads - .NET Framework Regular Expressions - Quick Reference

Version: 1.0

Date Published: 5/28/2014

File Name:

Regular expressions quick reference.docx, 70 KB

Regular expressions quick reference.pdf, 587 KB

This download is a document that provides information about the .NET Framework regular expression language. It's designed for quick lookup of characters, codes, groups, options, and other elements of regular expression patterns. It's provided in Microsoft Word (.docx) and .pdf formats.


If you don't regex often this cheat sheet might come in real handy. Or worse case it makes for cool cube art... :)

Tuesday, December 03, 2013

RegEx'ing - The RefCardz

DZone - Refcardz - 196: Regular Expressions

The Essential Regular Expressions Cheat Sheet

A regular expression, also known as a regex or regexp, is a way of defining a search pattern. This Refcard assumes no prior knowledge of regular expressions covers basic features of regular expressions, including normal and special characters, quantifiers, capturing and non-capturing groups, and more.


About Regular Expressions

A regular expression, also known as a regex or regexp, is a way of defining a search pattern. Think of regexes as wildcards on steroids. Using wildcards, *.txt matches any-thing followed by the string ".txt". But regular expressions let you e.g.: match specific characters, refer back to previous matches in the expression, include conditionals within the expression, and much more.
This Refcard assumes basic familiarity with program structures, but no prior knowledge of regular expressions. It would be wise to play with as many of the examples as possible, since mastering regex requires a good deal of practical experience.

There is no single standard that defines what regular expressions must and must not do, so this Refcard does not cover every regex version or 'flavor'. Parts of this Refcard will apply to some flavors (for example, PHP and Perl), while the same syntax will throw parse errors with other flavors (for example, JavaScript, which has a surprisingly poor regex engine).

Regular expressions are supported in most programming and scripting languages, including Java, .NET, Perl, Python, PHP, JavaScript, MySQL, Ruby, and XML. Languages that do not natively support regular expressions nearly always have libraries available to add support. If you prefer one regex flavor to the flavor the language natively supports, libraries are often available which will add support for your preferred flavor (albeit often using a slightly different syntax to the native expressions).


If you've been following me for any length of time you'll have heard me whine about how much I stink at regex'ing. I just don't do it near enough to feel comfortable with it, let alone even approach "good." Heck, I'm so far from good I can't see it with binoculars (on a clear day, flat plain, no wind... you get the picture). Man, I'm luckily I can even spell regex. In short, this cheat sheet was written just for me! I guess since it the holidays I can share though... :P

If I were really cool, I'd have created a regex that created that title instead of using literals... But today has been a long week and well, I guess I'll leave that as an exercise for all of you.

Saturday, May 12, 2012

The Regular Expression Skidmarklet (Prepare for much boy poo humor as you learn RegEx)

CodeProject - The Regular Expression Skidmarklet

"Regular expressions are hard. Reading about them is confusing and boring at best. Until you need the functionality they provide it’s hard to understand why they exist. You need to apply them to something you do everyday.

Following these lessons you’ll be taken through the assembly of a Skidmarklet... a JavaScript Bookmarklet that leverages Regular Expression matching and replacement to skidmark the crappy parts of any web page. Think about it this way, Regular expressions (or regex) are hard, everybody poops and we can all relate to that.

Click the button below to see the finished product in action or download the example files here.


Recent forays into fatherhood have revitalized my once rampant infatuation with poop. So let’s make my poop obsession your regular expression!

I developed the poop game when I was 17 working at Blockbuster Video. Don’t worry, it happened in the store not the toilet. For fun between the postal monotony of shelving cassette tapes I swapped poop for each word in a movie title. Using The Green Mile as an example there were three potential poop game results:

  1. Poop Green Mile
  2. The Poop Mile
  3. The Green Poop

One word at a time I’d just laugh at all the possible combinations and one word at a time customers would distance themselves from my creepy giggles as this all happened in my head. Here poop made a crappy job a little less of a turd. Regular Expressions have the power to smear joy and delight if only we can understand them. So let’s get to know them better by playing the poop game on the internet.


This had the boy, okay the man too, in me laughing as I was learning...

Wednesday, January 18, 2012

Learning RegEx - Grouping and Backlinks

Switch on the CodeRegular Expressions - Grouping

As we learned in our Regular Expressions Primer, regular expressions can be simple or extremely complex. However, there are a few concepts that were left out. Today we are going to cover one of those concepts... grouping.

In regular expressions, grouping allows you to "chunk" parts of your expression and tell the regular expression engine to treat each "chunk" as a separate match. This allows you to, say, find the type of domain (com, eu, biz) of an email address, or possibly whether or not the uri is using encrytion (https). There are a whole lot of reasons you want to use grouping, but enough talk, let's get to it. Today we will be using PHP yet again, but grouping is supported by any self-respecting regular expression engine.

The Basics of Grouping

Grouping is implemented with ()s. Anything inside the parentheses are considered a group, and are tracked by the order in which they appear in the expression. So if I have two groups, whichever appears first (from left to right) will be marked as match one, and match two will be the one that appears next. Some engines even allow sub-groups, but for today we will stick to single-scope groups.


Back References

When we are talking about regular expressions, back-references are references to groups that you can reference when replacing matches. In order to use back-references, you have groups defined in your expression.

Taking the example above, let's say we want to replace all the domains in a set of emails with "awesomesite". In PHP you use the preg_replace function, which uses regular expressions to replace text in a string. Let's check out how to use back-references to replace the domain in our email.



[Insert my usual, "I don't RegEx enough to remember this so I'm captuing this here so I can find it in the future the next time I have to RegEx" statement block here]

Sunday, January 15, 2012

[Quick VS Tip] Using regular expressions do the find/replace in Visual Studio

David Amador - Find/Replace in Visual Studio using regular expressions

Usually Find/Replace gets the job done for what I need, although sometimes using “Replace All” can break more stuff that it fixes.

But today I had this function I wanted to get rid of and simple change it with a public variable.
So I had something like this.
object->setLayer(/*BLABAL BLA CODE, */);

I want to replace it with something more simple
object->Z = /*BLABAL BLA CODE, */;

So using Visual Studio Find/Replace in regular expressions mode I used this as a search string

This is a find/replace tip that I want to keep handy and find in the future. Since I don't do this often, every time I do I have to relearn how to do it... With this, maybe the next time it won't take me as long... ;)

Saturday, July 02, 2011

RegEx'ing in Visual Studio with the Regular Expression Tester Extension

Visual Studio Gallery - Regular Expression Tester Extension


The tool provides the following features:

  • Parsing of your existing regular expressions from code for C# and VB.
  • Parentheses matching.
  • Instant compilation of your regular expressions as you type along with error message feedback.
  • Matches, groups and captures highlighted in color on your input data so you get an easy overview of exactly how your regular expression matches your data.
  • Saving regular expressions for later use.
  • Evaluation is performed in a background thread so it can be aborted if it gets stuck on an inefficient regular expression (try for instance (a|aa)*b on aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)




If you're RegEx'ing having an extension like this handy is a must...


Related Past Post XRef:
Free regular expression addin for Visual Studio - Regular Expression Explorer

The B, C and D's of Learning Regex...
"Regular Expression Cheat Sheet (.NET)" from RegExLibrary

Tuesday, May 10, 2011

Regex Hero (no, not you, the free Silverlight based Regex tester, library Regex Hero)

Farblondzshet in Code - Regex Hero: Free online regular expression tester

“A regex tester is one of those tools developers often need. I used many different ones over the years and have never settled on one that I really like. I have seen some paid ones that looked promising but I hoped to find a good free one. A few months ago I came across Regex Hero which is an online Silverlight based regex tester for .NET. It has both a free and a paid version ($15) . I have not used the paid version so my description is based solely on the free version.


Been a while since I’ve blogged about Regex and seeing Matthew’s post, the fact that Regex Hero is a Silverlight app, it provides .Net (C# & VB) code snips and the free version is very usable, well how could I pass it up?

Here’s some snips.


One of the cool things, being Silverlight, is that it can use local isolated storage. In short, it remembers what you did last on this machine when you revisit the site.

I mentioned .Net code snips?



The “reference” section provides a very simple quick look-up,reference for common regex expressions;


Via the tools menu you can also generate a permalink to a regex expression you’re working on for sharing…


For example,

And lastly you can save your expressions on the site and access a library of expressions from others;


Wednesday, March 23, 2011

The B, C and D's of Learning Regex...

.net Funda - B- Ball, C- Cat, D – dog: - Learning (REGEX) regular expression the easy way.

So, what’s the agenda?
Just in case if you are new comer, what is regex?
3 important regex commands
Check if the user has entered shivkoirala?
Let’s start with the first validation, enter character which exists between a-g?
Enter characters between [a-g] with length of 3?
Enter characters between [a-g] with maximum 3 characters and minimum 1 character?
How can I validate data with 8 digit fix numeric format like 91230456, 01237648 etc?
How to validate numeric data with minimum length of 3 and maximum of 7, ex -123, 1274667, 87654?
Validate invoice numbers which have formats like LJI1020, the first 3 characters are alphabets and remaining is 8 length number?
Check for format INV190203 or inv820830, with first 3 characters alphabets case insensitive and remaining 8 length numeric?
Can we see a simple validation for website URL’s?
Let’s see if your BCD works for email validation?
Short cuts
Quick references for regex

So, what’s the agenda?

Regex has been the most popular and easiest way of writing validations. The only big problem with regex has been the cryptic syntax. Developers who are working on projects with complicated validation always refer some kind of cheat sheet to remember the syntaxes and commands.

In this article we will try to understand what regex is and how to remember those cryptic syntaxes easily.




I regex about once a year, maybe. And like most it usually ends up being GBC (google based code). And every time I mean to learn it better, but then something comes up, yada, yada, yada. Well the next time I'm first going to review the above post (and then probably GBC it... but learning is a life long process, right?  :)

Thursday, March 03, 2011

"Regular Expression Cheat Sheet (.NET)" from RegExLibrary

RegExLibrary - Regular Expression Cheat Sheet (.NET)


The straight, simple, easy to understand an d very low signal to noise ration is what I thought cool about this... The Character Escapes/Character Classes also link to the appropriate MSDN doc's


Tuesday, August 11, 2009

Free regular expression addin for Visual Studio - Regular Expression Explorer

Visual Studio Gallery - Regular Expression Explorer


RegEx Explorer is a visual studio addin which lets you create or modify regular expressions and test them with any text. Matches are highlighted by surrounding each with a red box. A dropdown list of suggestions is available with choices for email, GUID, URL, etc. Any pattern you create can be added to the suggestion list. Existing suggestions can be removed by pressing DEL on a selected name.

Checkboxes are available for Ignore Case, Multiline and to auto-add or remove a ^$ wrapper. Patterns can be saved to be future suggestions. Patterns can be copied to the clipboard with a button press for pasting into your code. Matches are displayed in real-time as you type.

This add-in is offered for free, but donations are welcome if you like the utility. Also, please report any issues or make suggestions for changes.


Just a bit ago I was looking for some RegEx help, just something to play with different RegEx expressions, something built into my “day in and out work console” (aka Visual Studio ;)

This tool is just what I was looking for…