Note that there are some explanatory texts on larger screens.

plurals
  1. POIn need of regex assistance
    primarykey
    data
    text
    <p>Since I rarely write my own regular expressions, this is one of few times I'm not sure where to begin. I am faced with a problem dealing with an unknown number of integers delimited with dashes. Since it's hard to visualize, I'll give an example...</p> <pre><code>LHZ345-347-348-349-362-363-LMZ323-342-344-345-346-180100- </code></pre> <p>Given this statement, a regex should return:</p> <pre><code>LHZ345-347-348-349-362-363- LMZ323-342-344-345-346-180100- </code></pre> <p>With this is mind, I need to write a regex that checks for a 3 A-Z characters followed immediately by a 3 digit integer. From then on, any number of 3 digit integer + dash pairs may follow except for the last digit pair which may be of any length. Only dashes, integers 0-9, and capital characters A-Z are used.</p> <p>If there are any regex geniuses out there willing to help me out if this is a simply enough problem, that would be awesome. If not, It would be great if you could direct me to a site that you feel would be helpful. Thanks in advance for any assistance! - Brandon</p> <p><strong>Edit 1:</strong> As to show some attempts, <code>[A-Z]{3}...\d+-</code> is all I have. To my knowledge this should work, but I'm stuck at the unknown number of integers in the middle part.</p> <p><strong>Edit 2:</strong> What changes to the regexes posted in the answers below are needed to accept dashes OR > signs in between the 3 digit integers? Also, I can't seem to input the regex into preg_match() and have all test cases work yet the same regex works in online testers such as regexpal.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload