Regex

Currently Browsing Category 'Regex'

QueryString in JavaScript

by Captain Database on Nov 11th in JavaScript, Regex, Web Development

Here’s a simple one: you want to access the querystring via JavaScript. It seems like it should be so easy to do, but unfortunately, it’s not. In fact, doing it well can require some pretty heavy lifting depending on your algorithm. Well, I figured out a pretty easy way to do it with regular expressions [...]

Regex for Host File Entries

by Captain Database on Sep 21st in Regex

Since I’m rather addicted to regex, I always end up finding ways to use them for text parsing. I randomly felt the need to make one for host file entries: ^([^#\s]*)?\s*([^#\s]+\s*)*(#.*)?$ I know it might look like it’s more complicated than it needs to be, but this expression makes the entire parsing process incredibly simple. [...]

Regex for US Phone Numbers

by Captain Database on Sep 15th in Regex

I know that this is something people often say you can’t use regex for, but they’re wrong. If you want one magical regex that works for every possible country, extension, and format, then maybe that’s unreasonable. But with the right levels of internationalization, it’s certainly possible. So here is what I could come up with, [...]

Powered By Wordpress Designed By Ridgey