Tag: regex

Little TipsprogrammingWeb Development

Where Can I Learn Regular Expressions? How About Testing?

Where Can I Learn Regular Expressions Syntax and Use?

Regular expressions are fun, if you can figure out how to use use them of course. So, let’s fix that. Well, even better, just go fish on your own starting with Regular-Expressions. I kinda like how colorful that site is!

Where Can I Test My Regular Expressions?

If you are learning Regular Expressions, you probably wonder sometimes if there is a way to make sure what you have in mind will work. Well, there are several ways of testing your regex, but I have found Regex Tester to be pretty easy to use.

Et voilà! Look at you! All equipped and ready!

RafikiTechnology regular expression cheatsheet
Little TipsWeb Development

Regular Expression

This is more of a note-to-self type of post.

You know that series of symbols and characters in a chain following each other? Sometimes you will find them with a find, replace, or find and replace function.

Examples:

  • This processes a URL:
  • somefunction.replace(/^http[s]{0,1}:\/\/[^\/]*\/?/, '/')
  • From WordPress: The following example removes all HTML comments in the first pattern, and causes a favicon (with any filename extension) to be loaded from another domain in the second pattern:
    #<!--.*?-->#s =>
    #\bsrc="/(favicon\..*)"# => src="http://mycdn.somewhere.com/$1"

Well, they are called regular expressions and you can learn more about them at some of these sites:

Any comments, suggestions, or questions? Please drop a note.