11

I want to know what is more standard way to call regular expression in short way. I have seen both, regex and regexp.

Google says regex has almost 2 as much hits that regexp, but it depends on way I search it (when I add "regular expression" after the word, "regex" becomes "regex regular expression", the result is differend). And on stackexchange there is regex tag. :)

What is more proper way to shorten it?

Perhaps it does not matter. :) But thanks for answer.

4
  • How to shorten the word "regular expressions" isn't really a constructive question that's going to have a correct answer or provide anything more than a poll of people's preferences.
    – user8
    Aug 20, 2011 at 18:41
  • @Mark -- I do not see why this question was closed as "not meeting the guidelines". I can tick off the guidelines, and IMO it meets most of them. For instance, it is asked in an impartial tone, it invites discussion of why (as seen in some of the excellent answers), it invites sharing of experiences, and it is not merely "mindless fun".
    – Jay Elston
    Aug 20, 2011 at 21:56
  • @Jay I encourage you to take a look at the FAQ, specifically under the section on what not to ask and particularly the part where it says to avoid asking questions where every answer is equally valid and there's no actual problem to be solved. If you have any additional concerns or questions, feel free to ask about it on our meta discussion site.
    – user8
    Aug 20, 2011 at 22:03
  • Regexp is kind of old, IMHO. Sep 13, 2011 at 7:00

7 Answers 7

13

There's no right or wrong abbreviation here. It'll mostly be influenced by what APIs you're working with:

It's Regex!

It's Regexp!

It's something else entirely!

The fact that Jeffrey Friedl, author of the excellent Mastering Regular Expressions, lives at regex.info is good enough for me: I tend to call them regexes. But I keep this close at hand just in case I change my mind later...

s/\bregex\b/$&p/gi;
6
  • It's Rexexp in perl. Proof: Execute this one-liner: perl -le 'print ref(qr/re/)'. Or maybe its regex? "regex" wins out over "regexp" by a wide margin in man perlre. Aug 20, 2011 at 16:37
  • It's regex, FTW! Sep 13, 2011 at 6:59
  • This is a minor nit, but regular expressions aren't called "preg" in PHP. preg is the prefix for one set of regex functions that use the PCRE engine. Sep 13, 2011 at 10:46
  • @MattBelanger And they're not "called" // in Perl either. :) It was a general point about the various abbreviations or other conventions used between languages. Sep 13, 2011 at 12:52
  • 1
    @Mark Whitaker I blame posting at 6:30AM, before I've had my coffee :) Sep 13, 2011 at 13:05
11

As some indication - there's a Regex class in .NET and regex package in Java; not Regexp. Two fairly large 'ecosystems'. This by itself means more to me than as if some committee, somewhere, decided it this way or that way.

1
  • 4
    In Javascript, it's RegExp
    – user1827
    Aug 20, 2011 at 14:56
9

There is no standard that dictates this. As to what is more common, Google says regex vs. regexp by some 13.8 vs 9.8 million finds.

0
6

Regex is much more common, and you might get an odd glance or two if you say Regexp.

1
  • Unless, of course, you said it to a Rubyist. ;) Aug 20, 2011 at 14:07
2

I have never before this thread seen it shortened to regexp and always seen it as regex. Just to add to the list, the new C++ Standard has <regex>, not <regexp>.

1

what's more standard depends on the predominant language of the folks you're talking to, I would argue. Correct above about Regex in .NET and Java, but Ruby uses the Regexp class for regular expressions.

1

My answer is more morphological. Consider yourself as the first person who wants to provide an abbreviation for this concept (Definitely regex or regexp both come from somewhere and haven't been with us since Adam), and you know that it should come from regular and expression.

My dictionary tells me that reg. is an abbreviated form of regularly and exp. is a shorthand of express. Thus if you want to follow the rules of abbreviations, REGEXP seems more structural. However, forming new words (neologism as they call it) is not always straight and often is done by people who are not linguists. Considering these issues, to make a name which with a more aesthetically appealing pronunciation, you can create REGEX.

Also as a note, StackExchange editor considers regex as wrong spell, while regexp is fine :)

1
  • 1
    SE editor doesn't have Spell Check. Sep 13, 2011 at 7:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.