Talk:Regular expression

From Wikipedia, the free encyclopedia
Jump to: navigation, search
WikiProject Computing (Rated C-class, High-importance)
WikiProject icon This article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
C-Class article C  This article has been rated as C-Class on the project's quality scale.
 High  This article has been rated as High-importance on the project's importance scale.
 
WikiProject Computer science (Rated C-class, High-importance)
WikiProject icon This article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
C-Class article C  This article has been rated as C-Class on the project's quality scale.
 High  This article has been rated as High-importance on the project's importance scale.
 

Examples[edit]

Why all the examples are in PHP? Shouldn't they be in pseudocode or in a more-common-syntax language? I find that the $ in the variables names can be confused with the regexs syntax. 186.136.108.233 (talk) 13:52, 11 February 2014 (UTC)

I'm adding links to search online regular expression testers and to one specific example, which are an excellent way to explore regular expressions with sufficiently equipped browsers, but require Wikipedia:EL#Rich_media exensions. - Tatzelbrumm (talk) 10:52, 22 May 2014 (UTC)

The image example is awful, as it is showing an exact opposite of a regular expression. Positive look-behinds are NOT regular. --141.89.226.146 (talk) 23:30, 13 November 2015 (UTC)

Lookaround is used, but not explained[edit]

Hello,

In the example at the top of the page the lookaround "(?<=)" and "(?=)" groups are used but not explained in the text. I've added a link at the bottom to a Quick Start guide with at least a description. Can someone add the operators to some list in the page. The page indeed needs clean up. As a computer scientist I can say that the page is written from the point of view of a theoretical computer scientist, not the point of view of an average Wikipedia user.

Thanks!

Jgamleus (talk) 17:41, 17 July 2015 (UTC)

The "average Wikipedia user" will never use a regex in their life, but I agree that examples shouldn't contain syntax which isn't covered in the text. – Smyth\talk 13:53, 13 April 2016 (UTC)
There's additional similar functions which are powerful (can help reduce developer logic code, make use of more efficient regexp engine) but not even mentioned. For a reference, here's the Mozilla Developer's Network link ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions ). The following 3 examples are not Mozilla-centric, and can be found in e.g. PCRE docs. However, the mozilla-centric nature does omit the "lookaround" "(?=)" and "(?<=)" functionality, and unfortunately I am not familiar with them. Is there a corresponding "(?>=)" as well? They should all have proper examples given, but the only "lookaround" examples given are tacked on to "Word Boundaries" in the "ASCII" examples column, which is inadequate and inappropriate. I believe all of these belong in the Meta-Character(s) table, directly below "( )" "Groups a series" ...
"non-capturing parentheses" "(?:x)", which is handy if you use parenthesis for grouping, if you optionally want to match something which may or may not be present, but wish to discard the match, as in "discard_this match_everything_else" /(?:|discard_this )match_everything_else/ also matches "match_everything_else" by itself
"lookahead" "x(?=y)", which allows you to match something ONLY if followed by something else, "match_this but_only_if_that" matches /match_this(?= but_only_if_that)/ but "match_this and_not_anything_else" doesn't.
"negated lookahead" "x(?!y)" which inverts the lookahead logic, so "match_this but_only_if_that" /match_this(?! but_only_if_that)/ does NOT match, but "match_this and_not_anything_else" DOES match.
P.S. As an "average" WikiPedia user, and a hobby developer, I came here rather than trying to find all the various application-centric pages of each implementation.
P.P.S. You can use my examples, or modify them, for the Wiki page, if someone else can also verify their technical correctness.
Warp9pnt9 (talk) 16:15, 4 June 2016 (UTC)

pcre syntax highlighting lost[edit]

Please see Talk:Perl Compatible Regular Expressions#pcre syntax highlighting lost. John Vandenberg (chat) 06:48, 18 July 2015 (UTC)

Which: "?" or "="[edit]

I'm not an expert on regular expressions so don't want to edit myself. In the table of metacharacters there are two instances of "?". Should the second be "=" ? SolarMcPanel (talk) 11:12, 2 August 2016 (UTC)

Are you referring to the table at Regular expression##Examples? It has two rows starting:
? Matches the preceding pattern element zero or one time.
? Modifies the *, +, ? or {M,N}'d regex that comes before to match as few times as possible.
They are correct. The first gives H.?e as an example regex where the ? makes the . optional (zero or one occurrences matches). The second regex uses l.+?o where the ? modifies what the preceding + means. On its own, + matches the previous item one or more times, as many as possible. In combination, +? matches the previous item one or more times, as few as possible. Johnuniq (talk) 11:41, 2 August 2016 (UTC)

Pronunciation of regex[edit]

I've always heard and said rejex (I don't speak phonetics) and I'd be very surprised if anyone used a hard g, although it could be argued as logical.Andthepharaohs (talk) 19:12, 9 September 2016 (UTC)

Where did you first hear that? I've always heard/said it with a hard 'g', which as you point out is logical. FusionDude (talk) 20:33, 28 October 2016 (UTC)

Maybe its a Locale thing? In the UK, rejex was the norm (but I did retire 10 years ago and it may have suddenly changed). We might ask Ken Thompson who wrote the original unix code, but the usage is in the public domain now. A Google search reveals no concensus. So I would go with Larry Walls, the inventor of Perl, who reckoned, "There's always more than one way to do it". Javalava101 (talk) 12:58, 14 December 2016 (UTC)

Here in Germany in a multilingual work environment I've never heard "rejex" at all. It still sounds most peculiar to me ;-) --Alfe (talk) 13:53, 15 March 2017 (UTC)