Linked Questions
18 questions linked to/from How does the regular expression ‘(?<=#)[^#]+(?=#)’ work?
72 votes
7 answers
46k views
Regex: I want this AND that AND that... in any order
I'm not even sure if this is possible or not, but here's what I'd like. String: "NS306 FEBRUARY 20078/9/201013B1-9-1Low31 AUGUST 19870" I have a text box where I type in the search parameters and ...
22 votes
7 answers
7k views
is there a elegant way to parse a word and add spaces before capital letters
i need to parse some data and i want to convert AutomaticTrackingSystem to Automatic Tracking System essentially putting a space before any capital letter (besides the first one of course)
15 votes
4 answers
13k views
Regex to match all permutations of {1,2,3,4} without repetition
I am implementing the following problem in ruby. Here's the pattern that I want : 1234, 1324, 1432, 1423, 2341 and so on i.e. the digits in the four digit number should be between [1-4] and should ...
10 votes
6 answers
14k views
How can I get the last integer "56" from String like ra12ke43sh56?
How can I get the last integer "56" from String like ra12ke43sh56? I have to modify the next value as ra12ke43sh57 so I want to get the last the integer value.
3 votes
4 answers
18k views
Splitting a simple maths expression with regex
I am trying to have a regular expression split on equations like 1.5+4.2*(5+2) with operators - + * / so the output would be input into a array so I can parse individually [0]1.5 [1]+ [2]4.2 [3]* [4](...
5 votes
3 answers
10k views
PHP regexp for "start of string or pattern" [duplicate]
Is there a way (other than by doing two separate pattern matches) to use preg_match in PHP to test for either the beginning of the string or a pattern? More specifically I often find myself wanting to ...
2 votes
3 answers
8k views
How to make a regex for files ending in .php?
I'm trying to write a very simple regular expression that matches any file name that doesn't end in .php. I came up with the following... (.*?)(?!\.php)$ ...however this matches all filenames. If ...
3 votes
3 answers
3k views
Split string of varying length using regex
I don't know if this is possible using regex. I'm just asking in case someone knows the answer. I have a string ="hellohowareyou??". I need to split it like this [h, el, loh, owar, eyou?, ?]. The ...
3 votes
4 answers
14k views
Regex matching key="value" pattern
I want to match following pattern: key="value" key="value" key="value" key="value" ... where key and value are [a-z0-9]+, both should be grouped (2 groups, the " - chars can be matched or skipped) ...
5 votes
4 answers
345 views
Having trouble with Splitting text
Here's the code I'm using : public class splitText { public static void main(String[] args) { String x = "I lost my Phone. I shouldn't drive home alone"; String[] result = x.split("."); ...
4 votes
4 answers
1k views
Regex to calculate straight poker hand - Using ASCII CODE
In another question I learned how to calculate straight poker hand using regex (here). Now, by curiosity, the question is: can I use regex to calculate the same thing, using ASCII CODE? Something ...
2 votes
4 answers
10k views
Regex Rules for First and Second Character
I need help on following regular expression rules of javascript and php. JS var charFilter = new RegExp("^[A|B].+[^0123456789]$"); PHP if (!preg_match('/^[A|B].+[^0123456789]$/', $data_array['...
2 votes
3 answers
2k views
Java \ Pattern - how to write a pattern that verifies the lack of a string?
I tried from https://docs.oracle.com/javase/1.5.0/docs/api/java/util/regex/Pattern.html. I have Pattern PATTERN = Pattern.compile("agg{0}.*"); Matcher m = PATTERN.matcher("...
4 votes
1 answer
683 views
Matching a^n A^n with regular expression
We're learning about the difference between regular languages and regex, and the teacher explained that the language a^n b^n is not regular, but she said that most regex flavors can match a^n A^n ...
2 votes
2 answers
3k views
Regex : negative assertion
I'm stuck with an easy regex to match URLs in a content. The goal is to remove the folder from the links like "/folder/id/123" and to replace them with "id/123" so it's a short relative one in the ...