My string looks like so
February 2009
bla bla
March 2009
doo daa bla lbla
Septemer 2009
So I wrote this regex to split it up into months (which is what I want to do first, I think)
$regex = '/(.*)\s(\d){4}/i';
This matches them perfectly, except it throws away the actual string they were split on .. i.e. I wa...
What regular expression mechanism can be used to match "ski" but not "water ski"?
Or, match "ski" but not "ski sale"?
Could a short explanation be included?
Update: i mean, for example, it should be able to match "2009 ski competition" but not "2009 water ski competition".
...
Thanks to S. Gehrig's answer in the initial question I've got a regex which works fine and validates a variable based on the Letter property (except Chinese, but that's another topic :):
if (preg_match('/^\p{L}+$/u', $input)) {
// OK
}
Unfortunately I can't extend it to support to support numbers respective question/exclamation & ...
I am looking for a function that would be able to do the same thing as the MySQL REGEX function for TSQL.
Basically i need my Query to look something like the following:
SELECT * FROM Routing WHERE (@Message REGEX RouteRegex);
I am not to keen to use CLR at this point in time.
Any Ideas?
...
Hi,
I'm trying to match a string and then use grouping to create a new string:
(let ((url (browse-url-url-at-point)))
(if (string-match "http://domain/\\([0-9]+\\)/\\([a-z]+\\)\.\\([0-9]+\\)" url)
(setq filename (concat (match-string 1 url) "_" (match-string 2) "." (match-string 3) ".xml"))))
When I (print url) I get the foll...
I have the following regex to try to reduce groups of newlines:
s/(\n|\r\n|\n\r)(\n|\r\n|\n\r)(\n|\r\n|\n\r)+/\n\n/gmi;
It started out as:
s/\n\n(\n)+/\n\n/gmi
I am looking to reduce the number of newlines that are continuous to a maximum of two in a row (just trying to do some cleanup on some files that I am importing for an inter...
I asked this question a long time ago,
I wish I had read the answers to
When not to use Regex in C# (or
Java, C++ etc) first!
I wish to use Regex (regular expressions) to get a list of all strings in my C# source code, including strings that have double quotes embedded in them.
This should not be hard, however before I spen...
Hi,
I want to extract the http link from inside the anchor tags? The extension that should be extracted should be WMV files only.
...
I've been writing a plugin for Joomla that automatically processes HTML comments eg. {dropcap}B{/dropcap} and creates a drop cap style.
I needed a way to pass on parameters to the plugin so therefore decided the best way would be: {dropcap}B|FF00FF|00FF00{/dropcap}.
I created a function:
if (preg_match_all('/{dropcap}(.+?){\/dropcap}/...
I use the following to remove white space and :.
For example ' e-post: ' becomes 'e-post'.
replace(/\s/g,"").replace(/:/g,"");
But I know there is a better way to do it by using only one 'replace'.
Could anyone help me please?
Thanks in advance.
...
This is my first time working with regular expressions and I've been trying to get a regular expression working that would match the following:
apple
apple inc.
apple co.
apple corp.
but would not match:
inc. apple
co. apple
apple co. inc.
apple corp. inc.
apple inc. corp.
and so on...
This is what I got so far (apple)\s(inc|co...
I'm trying to think of a regular expression for this but not having any luck..
Let's say you have a security question on you website so the person can recover a password. People often forget exactly how they entered information. For example, given the question "What company do you work for?", a user might answer "Microsoft Corp.". But ...
Hi guys,
I currently have the regex:
(?:(?:CD)|(?:DISC)|(?:DISK)|(?:PART))([0-9]+)
currently this will match CD1, DISK2 etc
I need it too be able to pick up CD02 (with two digits) as well as CD2 but I only seem to be able to do one or the other, and my regex skills are pretty useless.
I'm using this code in C#
thanks for your help...
I'm writing my second python script to try and parse the contents of a config file and would like some noob advice. I'm not sure if its best to use regex to parse my script since its multiple lines? I've also been reading about dictionaries and wondered if this would be good practice. I'm not necessarily looking for the code just a push ...
from django import forms
class ActonForm(forms.Form):
creator = forms.RegexField('^[a-zA-Z0-9\-' ]$',max_length=30, min_length=3)
data = {'creator': 'hello'
}
f = ActonForm(data)
print f.is_valid()
Why doesn't this work? have i made a wrong regular expression? I wanted a name field with provision for single quotes and a hy...
Hi all,
I need to validate a textbox input and can only allow decimal inputs like:
X,XXX (only one digit before decimal sign and a precision of 3)
I'm using c#
Should it be something like ^[0-9]+(.[0-9]{1,2})?$
Thanks!!!
...
It is clear that there are lots of problems that look like a simple regex expression will solve, but which prove to be very hard to solve with regex.
So how does someone that is not an expert in regex, know if he/she should be learning regex to solve a given problem?
(See "Regex to parse C# source code to find all strings" for way I am...
Hi,
how to match all contents outside a HTML tag?
My pseudo-HTML is:
<h1>aaa</h1>
bbb <img src="bla" /> ccc
<div>ddd</div>
I used the regular expression,
(?<=^|>)[^><]+?(?=<|$)
which would give me: "aaa bbb ccc ddd"
All I need is a way to ignore HTML tags with return: "bbb ccc"
...
I am looking for a quick way to parse HTML tags out of a Coldfusion string. We are pulling in an RSS feed that that could potentially have anything in it. We are then doing some manipulation of the information and then spitting it back out to another place. Currently we are doing this with a regular expression. Is there a better way to d...
How can I write a RE which validates the URLs without the scheme:
Pass:
www.example.com
example.com
Fail:
http://www.example.com
...