# RegEx

**URL:** <https://rubytalk.org/t/regex/70429>\
**Category:** ruby-talk\
**Created:** [18 November 2014 12:22 UTC](https://rubytalk.org/t/regex/70429 "2014-11-18T12:22:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Boris1](https://avatars.discourse-cdn.com/v4/letter/b/e9a140/32.png) [@Boris1](https://rubytalk.org/u/Boris1)\
**Post date:** [18 November 2014 12:22 UTC](https://rubytalk.org/t/regex/70429/1 "2014-11-18T12:22:30Z")

</div>

Hi all, I have such a question. Is it really important to know very well  
regular expressions, if I am not going to be a web designer? What about a  
web developer? Is it true that regex is most usable with strings matching.  
I know that it will take much time to cover this topic so what do you say?  
To learn or not to learn? Is it really needed? What is the main field of  
RegEx workability? Thank you!

> **···**
>
> -------------------------------------
> 
> Празнична промоция на хостинг! Неограничен трафик и много екстри с 57% отстъпка!  
> [http://www.superhosting.bg/promo/9years?utm\_source=Mail.BG&utm\_medium=Footer&utm\_content=v2&utm\_campaign=9years](http://www.superhosting.bg/promo/9years?utm_source=Mail.BG&utm_medium=Footer&utm_content=v2&utm_campaign=9years)

---

<div class="post-metadata">

**Author:** ![bruka](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@bruka](https://rubytalk.org/u/bruka)\
**Post date:** [18 November 2014 14:03 UTC](https://rubytalk.org/t/regex/70429/2 "2014-11-18T14:03:31Z")

</div>

Getting back to the original question:

> Is it really important to know very well regular expressions,  
> if I am not going to be a web designer?  
> What about a web developer?

Regular expressions are a vast and beautiful subject. However for  
someone starting out in the field, I would consider them lower  
priority. You should first get a couple of programming languages under  
your belt, some basic SQL, a framework or 2, and in the process you're  
bound to pick up some regex.

I've been a professional web application developer for about 5 years  
now, and though I do use regular expressions frequently, my basic  
knowledge of them does not limit me from getting my work done. There  
are always multiple solutions to a problem and though regex are fast,  
succinct and elegant, they are never the only solution. Plus the web  
will provide you with 80% of the regex you will ever need.

There is also the flip side argument that regular expressions, once  
written, can be impossible to decipher and modify. It is very, very  
hard to debug code that relies extensively on regular expression.

Regardless, regular expressions are a fantastic tool, just not hugely  
important for someone starting out as a programmer. I would not put  
your other learning on hold while you read a regex book.

> **···**
>
> On Tue, Nov 18, 2014 at 7:22 AM, \<sata@mail.bg\> wrote:
> 
> > Hi all, I have such a question. Is it really important to know very well  
> > regular expressions, if I am not going to be a web designer? What about a  
> > web developer? Is it true that regex is most usable with strings matching. I  
> > know that it will take much time to cover this topic so what do you say? To  
> > learn or not to learn? Is it really needed? What is the main field of RegEx  
> > workability? Thank you!
> > 
> > -------------------------------------  
> > Празнична промоция на хостинг! Неограничен трафик и много екстри с 57%  
> > отстъпка!

---

<div class="post-metadata">

**Author:** ![Xavier\_Noria](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/xavier_noria/32/1867_2.png) [@Xavier\_Noria](https://rubytalk.org/u/Xavier_Noria)\
**Post date:** [18 November 2014 12:32 UTC](https://rubytalk.org/t/regex/70429/3 "2014-11-18T12:32:10Z")

</div>

Regular expressions are an amazing and powerful tool that any programmer  
should master no matter their domain.

Yes, learn them.

---

<div class="post-metadata">

**Author:** ![Carlos\_Agarie](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Carlos\_Agarie](https://rubytalk.org/u/Carlos_Agarie)\
**Post date:** [18 November 2014 13:12 UTC](https://rubytalk.org/t/regex/70429/4 "2014-11-18T13:12:16Z")

</div>

sata,

I personally recommend the book "Mastering Regular Expressions":

> **[Mastering Regular Expressions, 3rd Edition](https://www.oreilly.com/library/view/mastering-regular-expressions/0596528124/)**
>
> Regular expressions are an extremely powerful tool for manipulating text and data. They are now standard features in a wide range of languages and popular tools, including Perl, Python, Ruby, … - Selection from Mastering Regular Expressions, 3rd...

It is a dense book and will probably need to be read more than once, but it  
is worth it.

You can always read the documentation on Ruby's Regexp class as well:

> **[Class: Regexp (Ruby 2.1.4)](https://ruby-doc.org/core-2.1.4/Regexp.html)**
>
> Class : Regexp - Ruby 2.1.4

> **···**
>
> -----  
> Carlos Agarie  
> Software Engineer  
> +55 11 97320-3878 | @carlos\_agarie
> 
> 2014-11-18 11:08 GMT-02:00 \<sata@mail.bg\>:
> 
> > Thank you Xavier! Do you have any source suggestion? I have some in mind  
> > but do you share your opinion or it does't matter what source I'll start  
> > out to read. Is it well compatible with ruby?
> > 
> > ----- Цитат от Xavier Noria (fxn@hashref.com), на 18.11.2014 в 14:32 -----
> > 
> > Regular expressions are an amazing and powerful tool that any programmer  
> > should master no matter their domain.
> > 
> > Yes, learn them.
> > 
> > -------------------------------------  
> > Mail.BG \<[http://mail.bg](http://mail.bg)\>: Безплатен e-mail адрес. Най-добрите  
> > характеристики на българския пазар - 20 GB пощенска кутия, 1 GB прикрепен  
> > файл, безплатен POP3, мобилна версия, SMS известяване и други.

---

<div class="post-metadata">

**Author:** ![Boris1](https://avatars.discourse-cdn.com/v4/letter/b/e9a140/32.png) [@Boris1](https://rubytalk.org/u/Boris1)\
**Post date:** [18 November 2014 13:08 UTC](https://rubytalk.org/t/regex/70429/5 "2014-11-18T13:08:01Z")

</div>

Thank you Xavier! Do you have any source suggestion? I have some in mind  
but do you share your opinion or it does't matter what source I'll start  
out to read. Is it well compatible with ruby?

----- Цитат от Xavier Noria ([fxn@hashref.com](mailto:fxn@hashref.com)), на 18.11.2014 в  
14:32 ----- Regular expressions are an amazing and powerful tool that any  
programmer should master no matter their domain.  
Yes, learn them.

> **···**
>
> -------------------------------------  
> [Mail.BG](http://Mail.BG): Безплатен e-mail адрес. Най-добрите характеристики на българския пазар - 20 GB пощенска кутия, 1 GB прикрепен файл, безплатен POP3, мобилна версия, SMS известяване и други. [http://mail.bg](http://mail.bg)

---

<div class="post-metadata">

**Author:** ![Xavier\_Noria](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/xavier_noria/32/1867_2.png) [@Xavier\_Noria](https://rubytalk.org/u/Xavier_Noria)\
**Post date:** [18 November 2014 13:18 UTC](https://rubytalk.org/t/regex/70429/6 "2014-11-18T13:18:08Z")

</div>

The book Carlos recommends is one of the best technical books I've read.

That's the bible though, you could start with the documentation of Regexp,  
also mentionged by Carlos, or read the tutorial in the official Perl  
documentation

&nbsp;&nbsp;&nbsp;&nbsp;[http://perldoc.perl.org/perlretut.html](http://perldoc.perl.org/perlretut.html)

The syntax differences are not important, and the regexps themselves are  
incompatible only in advanced stuff you do not need to care now.

---

<div class="post-metadata">

**Author:** ![Boris1](https://avatars.discourse-cdn.com/v4/letter/b/e9a140/32.png) [@Boris1](https://rubytalk.org/u/Boris1)\
**Post date:** [18 November 2014 14:23 UTC](https://rubytalk.org/t/regex/70429/7 "2014-11-18T14:23:58Z")

</div>

Thanks to all you for answers. It was great help, especially on you Bruka.  
Maybe I should start to learn them later. However they are very exciting  
tool and maybe I'll read meanwhile.

----- Цитат от bruka ([bruka@idatainc.com](mailto:bruka@idatainc.com)), на 18.11.2014 в 16:03  
----- Getting back to the original question:

Is it really important to know very well regular expressions,  
if I am not going to be a web designer?  
What about a web developer?

Regular expressions are a vast and beautiful subject. However for  
someone starting out in the field, I would consider them lower  
priority. You should first get a couple of programming languages under  
your belt, some basic SQL, a framework or 2, and in the process you're  
bound to pick up some regex.

I've been a professional web application developer for about 5 years  
now, and though I do use regular expressions frequently, my basic  
knowledge of them does not limit me from getting my work done. There  
are always multiple solutions to a problem and though regex are fast,  
succinct and elegant, they are never the only solution. Plus the web  
will provide you with 80% of the regex you will ever need.

There is also the flip side argument that regular expressions, once  
written, can be impossible to decipher and modify. It is very, very  
hard to debug code that relies extensively on regular expression.

Regardless, regular expressions are a fantastic tool, just not hugely  
important for someone starting out as a programmer. I would not put  
your other learning on hold while you read a regex book.

> **···**
>
> On Tue, Nov 18, 2014 at 7:22 AM, wrote:  
> Hi all, I have such a question. Is it really important to know very well  
> regular expressions, if I am not going to be a web designer? What about a  
> web developer? Is it true that regex is most usable with strings matching.  
> I  
> know that it will take much time to cover this topic so what do you say?  
> To  
> learn or not to learn? Is it really needed? What is the main field of  
> RegEx  
> workability? Thank you!
> 
> -------------------------------------  
> Празнична промоция на хостинг!  
> Неограничен трафик и много екстри с 57%  
> отстъпка!
> 
> -------------------------------------
> 
> СуперХостинг.БГ стават на 9! Вземи хостинг с неограничен трафик с 57% отстъпка!  
> [http://www.superhosting.bg/promo/9years?utm\_source=Mail.BG&utm\_medium=Footer&utm\_content=v1&utm\_campaign=9years](http://www.superhosting.bg/promo/9years?utm_source=Mail.BG&utm_medium=Footer&utm_content=v1&utm_campaign=9years)

---

<div class="post-metadata">

**Author:** ![Eigil\_Sagafos](https://avatars.discourse-cdn.com/v4/letter/e/da6949/32.png) [@Eigil\_Sagafos](https://rubytalk.org/u/Eigil_Sagafos)\
**Post date:** [18 November 2014 13:15 UTC](https://rubytalk.org/t/regex/70429/8 "2014-11-18T13:15:19Z")

</div>

You should also check out [http://rubular.com/](http://rubular.com/) once you have covered the basics. It’s an interactive way to play around with regular expressions.

Eigil

> **···**
>
> —  
> Sent from Mailbox
> 
> On tirsdag, nov. 18, 2014 at 5:08 a.m., [sata@mail.bg](mailto:sata@mail.bg) \<[sata@mail.bg](mailto:sata@mail.bg)\>, wrote:  
> Thank you Xavier! Do you have any source suggestion? I have some in mind but do you share your opinion or it does't matter what source I'll start out to read. Is it well compatible with ruby?
> 
> ----- Цитат от Xavier Noria ([fxn@hashref.com](mailto:fxn@hashref.com)), на 18.11.2014 в 14:32 -----
> 
> Regular expressions are an amazing and powerful tool that any programmer should master no matter their domain.
> 
> Yes, learn them.
> 
> -------------------------------------  
> [Mail.BG](http://Mail.BG): Безплатен e-mail адрес. Най-добрите характеристики на българския пазар - 20 GB пощенска кутия, 1 GB прикрепен файл, безплатен POP3, мобилна версия, SMS известяване и други.

---

<div class="post-metadata">

**Author:** ![Robert\_K1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/robert_k1/32/1830_2.png) [@Robert\_K1](https://rubytalk.org/u/Robert_K1)\
**Post date:** [18 November 2014 13:17 UTC](https://rubytalk.org/t/regex/70429/9 "2014-11-18T13:17:52Z")

</div>

There is also [http://weitz.de/regex-coach/](http://weitz.de/regex-coach/) (runs also on Linux under  
Wine). It is not exactly Ruby regex but it is an amazing tool to watch  
the matching process and debug expressions.

Cheers

robert

> **···**
>
> On Tue, Nov 18, 2014 at 2:15 PM, Eigil Sagafos \<eigil@sagafos.no\> wrote:
> 
> > You should also check out [http://rubular.com/](http://rubular.com/) once you have covered the  
> > basics. It’s an interactive way to play around with regular expressions.
> 
> --  
> [guy, jim].each {|him| remember.him do |as, often| as.you\_can - without end}  
> [http://blog.rubybestpractices.com/](http://blog.rubybestpractices.com/)

---

<div class="post-metadata">

**Author:** ![Eric\_MSP\_Veith](https://avatars.discourse-cdn.com/v4/letter/e/ecd19e/32.png) [@Eric\_MSP\_Veith](https://rubytalk.org/u/Eric_MSP_Veith)\
**Post date:** [20 November 2014 22:28 UTC](https://rubytalk.org/t/regex/70429/10 "2014-11-20T22:28:54Z")

</div>

This might become a flame war, and certainly opens up a lot of possibilities  
for discussion, but I would never discard regulard expressions as lower  
priority.

RegExpes are not hard to learn, especially if you cover the basics. Mastering  
them, of course, is an entirely different topic, but that doesn't mean that  
you should learn them later. Parsing strings is much more common work than one  
might think, and being proficient with the basics of regular expressions  
really helps a lot. At least, its better than to use all the other awkward  
string function just to get pieces extracted from a string.

Once you've covered the basics of regular expressions, you'll never need any  
other string search/concat/edit function. Plus, regexpes work nearly  
everywhere.

Just my two cents.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--- Eric

> **···**
>
> On Tuesday 18 November 2014 14:23:58, Boris Atanasov \<sata@mail.bg\> wrote:
> 
> > Thanks to all you for answers. It was great help, especially on you Bruka.  
> > Maybe I should start to learn them later. However they are very exciting  
> > tool and maybe I'll read meanwhile.
> > 
> > ----- Цитат от bruka (bruka@idatainc.com), на 18.11.2014 в 16:03  
> > ----- Getting back to the original question:
> > 
> > Is it really important to know very well regular expressions,  
> > if I am not going to be a web designer?  
> > What about a web developer?
> > 
> > Regular expressions are a vast and beautiful subject. However for  
> > someone starting out in the field, I would consider them lower  
> > priority. You should first get a couple of programming languages under  
> > your belt, some basic SQL, a framework or 2, and in the process you're  
> > bound to pick up some regex.

---

<div class="post-metadata">

**Author:** ![Arup\_Rakshit1](https://avatars.discourse-cdn.com/v4/letter/a/c6cbf5/32.png) [@Arup\_Rakshit1](https://rubytalk.org/u/Arup_Rakshit1)\
**Post date:** [18 November 2014 14:48 UTC](https://rubytalk.org/t/regex/70429/11 "2014-11-18T14:48:53Z")

</div>

Thanks Robert for sharing this. 🙂

> **···**
>
> On Tuesday, November 18, 2014 02:17:52 PM Robert Klemme wrote:
> 
> > On Tue, Nov 18, 2014 at 2:15 PM, Eigil Sagafos \<eigil@sagafos.no\> wrote:  
> > \> You should also check out [http://rubular.com/](http://rubular.com/) once you have covered the  
> > \> basics. It’s an interactive way to play around with regular expressions.
> > 
> > There is also [The Regex Coach - interactive regular expressions](http://weitz.de/regex-coach/) (runs also on Linux under  
> > Wine). It is not exactly Ruby regex but it is an amazing tool to watch  
> > the matching process and debug expressions.
> > 
> > Cheers
> > 
> > robert
> 
> # --
> 
> # Regards, Arup Rakshit
> 
> Debugging is twice as hard as writing the code in the first place. Therefore,  
> if you write the code as cleverly as possible, you are, by definition, not  
> smart enough to debug it.
> 
> --Brian Kernighan
