Which is the correct shorthand - "regex" or "regexp"

RegexTerminology

Regex Problem Overview


Most of us computer programmers are pretty obsessed about correct terminology. I certainly am, especially because sometimes changing just one character in a word can drastically change its meaning.

So... what is the correct shorthand for "regular expression"? Is it "regex" or "regexp"? On the internet I see both uses, although "regex" seems to be more popular, and the tag list here on SO also includes just "regex". But plenty of people also use "regexp" in their questions.

Regex Solutions


Solution 1 - Regex

/regexp?/    

Solution 2 - Regex

Googlefight says regex wins, 685000 to 289000 (which is about 2.37:1).

Also, regexp is strange to say out loud because there are so few (if any?) words that end in a "-ksp" sound, but there are plenty of words that end in a "-ecks" sound.

Solution 3 - Regex

They are both OK. "regex" is more common, but "regexp" has been used more widely than the other answers here indicate. Some examples:

Solution 4 - Regex

regex is shorter; therefore, better :) Also, it is easier to pronounce.

Solution 5 - Regex

The accepted shorthand is "regex".

"Regexp" is only used, in my experience, in the context of Javascript where the object representing a regular expression is actually called RegExp.

Solution 6 - Regex

I think "regex" is more common (e.g., Java package java.util.regex). If 10,000 Elvis fans can't be wrong, then I'd vote for that on the strength of numbers.

Solution 7 - Regex

According to Wikipedia

> In computing, regular expressions, > also referred to as regex or regexp, > ...

Solution 8 - Regex

I think it's time to quit thinking in terms of shorthands or abbreviations. The regexes that we use in our daily tasks are a different breed entirely from the regular expressions of computer science or formal language theory. This is why Larry Wall and other prominent members of the Perl community have preferred "regex" for years: to call them RegExp or RegEx, or even RE, suggests a relationship that no longer applies.

Solution 9 - Regex

"regex" is more common and what is used in the Perl FAQ. Google gives 4.5 million hits for "regex" and 3.6 million for "regexp." Wikipedia uses both.

What do you prefer? I don't think anyone will think of you badly if you use them interchangeably.

Solution 10 - Regex

I would say it's "regex", this is based on my own experience, how I've heard it, and the community discussion here.

I can't find it at the moment, but this discussion was on meta over tags on SO, which is why this is the only question tagged "regexp", the rest (8441 and counting) are tagged "regex".


Just a side thought here: does it matter which is "correct?" Think about the purpose here, why do you use any word? To communicate. To a certain degree, it doesn't matter what's correct or not, it matters which one you can effectively communicate to more people. I would say you could easily argue to use an incorrect term, if that's what the majority of your audience uses, since communication is your goal.

Solution 11 - Regex

I have also heard/read:

reg-exp

And some people prefer regex because the plural regexes is "nicer"! (in addition to reasons explained by other answers).

.NET regex : System.Text.RegularExpressions.Regex

JavaScript regexp : RegExp

Solution 12 - Regex

Both are fine for written discourse, though you probably don't want to say "regexp" out loud too often ;)

For use in code, I think regexp is probably clearer. Especially if you use capitalization such as RegEx/RegExp. An Ex suffix is often used to indicate an extended version of a simpler function... i.e. CreateWindow/CreateWindowEx in the Windows API, so RegExp might be a little less ambiguous as far as readability of code goes.

Solution 13 - Regex

I prefer "re", but it depends on the language. JavaScript lists it as "RegExp", whereas most other languages just call it "RegEx."

When googling, go with the shorter version. But in forums, use "re" ;)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVilx-View Question on Stackoverflow
Solution 1 - RegexMatt StephensonView Answer on Stackoverflow
Solution 2 - RegexMark RushakoffView Answer on Stackoverflow
Solution 3 - Regexuser85509View Answer on Stackoverflow
Solution 4 - RegexhoubysoftView Answer on Stackoverflow
Solution 5 - RegexcletusView Answer on Stackoverflow
Solution 6 - RegexduffymoView Answer on Stackoverflow
Solution 7 - RegexRomain HippeauView Answer on Stackoverflow
Solution 8 - RegexAlan MooreView Answer on Stackoverflow
Solution 9 - RegexdawgView Answer on Stackoverflow
Solution 10 - RegexNick CraverView Answer on Stackoverflow
Solution 11 - RegexpolkduranView Answer on Stackoverflow
Solution 12 - RegexGeraldView Answer on Stackoverflow
Solution 13 - Regexvol7ronView Answer on Stackoverflow