I have a Drupal module which allow regex check of a text field. To check a valid birth year of 4+ years old, the valid range is year 1900 to 2006.
So assume the input string must be 4-char long. What's the regex to check the string is in that range? Thanks!
...
How to split a string on numbers and substrings?
Input: 34AG34A
Expected output: {"34","AG","34","A"}
I have tried with Regex.Split() function, but I can not figure out what pattern would work.
Any ideas?
...
Suggestion for a reference question. Stack Overflow has dozens of "How to parse HTML" questions coming in every day. However, it is very difficult to close as a duplicate because most questions deal with the specific scenario presented by the asker. This question is an attempt to build a generic "reference question" that covers all a...
One of my homework questions asked to develop a regex for all strings over x,y,z that did not contain xxx
After doing some reading I found out about negative lookahead and made this which works great:
(x(?!xx)|y|z)*
Still, in the spirit of completeness, is there anyway to write this without negative lookahead?
Reading I have done mak...
Hi,
I'm trying to get the code of a html document in specific tags.
My method works for some tags, but not all, and it not work for the tag's content I want to get.
Here is my code:
<html>
<head></head>
<body>
<?php
$url = "http://sf.backpage.com/MusicInstruction/";
$data = file_get_contents($url);
$pattern = "/<di...
Good day.
Little problem with regexp.
I have a regexp that look like
rexp2 = re.findall(r'<p>(.*?)</p>', data)
And i need to grab all in
<div id="header">
<h1></h1>
<p>
localhost OpenWrt Backfire<br />
Load: 0.00 0.00 0.00<br />
Hostname: localhost
</p>
</div>
But my code doesnt work :(
What im doing wrong?
...
I'm trying to find a certain sequence in the text of several .txt files. I am looking for a string that is joined to a 4 digit number. e.g. Watson1990. I tested the regex using an online tester and it appeared to work, however the expression (or combinations of it) failed to produce an output on my files.
My regular expression is as fol...
I am trying to match a multi line text using java. When I use the Pattern class with the Pattern.MULTILINE modifier, I am able to match, but I am not able to do so with (?m).
The same pattern with (?m) and using String.matches does not seem to work.
I am sure I am missing something, but no idea what. Am not very good at regular express...
I was reading the Java project idea described here:
The user gives examples of what he wants and does not want to match. The program tries to deduce a regex that fits the examples. Then it generates examples that would fit and not fit. The user corrects the examples it got wrong, and it composes a new regex. Iteratively, you get a re...
I'm busy trying to create two regular expressions to filter the id from youtube and vimeo video's. I've already got the following expressions;
YouTube: (youtube\.com/)(.*)v=([a-zA-Z0-9-_]+)
Vimeo: vimeo\.com/([0-9]+)$
As i explained below there are 2 types of urls matched by the regular expressions i already created. Several other ty...
Hi, I want to be able to do a regex match on a variable and assign the results to the variable itself. What is the best way to do it?
I want to essentially combine lines 2 and 3 in a single line of code:
$variable = "some string";
$variable =~ /(find something).*/;
$variable = $1;
Is there a shorter/simpler way to do this? Am I missi...
I want to use regular expressions inside my routes. I have an Products controller, but I want a different URL structure to access the products
http://host/this/
http://host/that/
http://host/andthat/
These URLs should call a action in my controller (Products:show_category(:category))
Is something like this possible?
match "(this|th...
Here's a string that I may have:
(MyStringIsOneWholeWord *)
I have used the following javascript regular expression to get the text after the bracket if it starts with My.
/(^|\s|\()+My(\w+)/g,
The problem with this is that it includes the first bracket in the result, as that it is the letter/character that found it.
How would I ...
I need my users to input very specific cell phone format cause my app will be sending sms to them
So, I need their cell phone formats to be like this
04AB-XXXXXXX
Where A can be either 1 or 2
and B can be either 2, 4 or 6
X can be from 0-9
There must be exactly 7 numbers (X) after 04AB
It must always start with 04
Examples:
...
First lets define a "URL" according to my requirements.
The only protocols optionally allowed are http:// and https://
then a mandatory domain name like stackoverflow.com
then optionally the rest of url components (path, query, hash, ...)
For reference a list of valid and invalid url's according to my requirements
VALID
stackoverf...
I'm making a classifieds ads website where users submit ads through a form (like Craigslist). Many users write the title or description of their ads in UPPERCASE to get more attention, but I dont want to affect the overall appearance of the website.
I would like to stop this, but still allow the use of acronyms of less than three upper...
I need to split a string on any of the following sequences:
1 or more spaces
0 or more spaces, followed by a comma, followed by 0 or more spaces,
0 or more spaces, followed by "=>", followed by 0 or more spaces
Haven't had experience doing Java regexs before, so I'm a little confused. Thanks!
Example:
add r10,r12 => r10
store r10 => ...
How would I go about removing numbers and a space from the start of a string?
For example, from '13 Adam Court, Cannock' remove '13 '.
...
How would I go about removing numbers and a space from the start of a string?
For example, from '13 Adam Court, Cannock' remove '13 '
Thanks!
(Apologies for near duplicate, I realised I need to use PHP to achieve this)
...
I'm trying to convert URLs, but not if they come after src=". So far, I have this...
return preg_replace('@(?!^src=")(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.-]*(\?\S+)?)?)?)@', '<a href="$1" target="_blank">$1</a>', $s);
It converts the URL, but even if it is before src="
...