I have a string which is like this:
this is "a test"
I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:
['this','is','a test']
PS. I know you are going to ask "what happens if there are quotes within the quotes, well, in my application, that will never...
Is there a quick way to find every match of a regular expression in Ruby? I've looked through the Regex object in the Ruby STL and searched on Google to no avail. Thanks!
...
I have a string which starts with //#... goes upto the newline characater. I have figured out the regex for the which is this ..#([^\n]*).
My question is how do you remove this line from a file if the following condition matches
...
I am trying to write some JavaScript RegEx to replace user inputed tags with real html tags, so [b] will become <b> and so forth. the RegEx i am using looks like so
var exptags = /\[(b|u|i|s|center|code){1}]((.){1,}?)\[\/(\1){1}]/ig;
with the following JavaScript
s.replace(exptags,"<$1>$2</$1>");
this works fine for single nested t...
Hi,
I have a version number of the following form:
version.release.modification
where version, release and modification are either a set of digits or the '*' wildcard character. Additionally, any of these numbers (and any preceding .) may be missing.
So the following are valid and parse as:
1.23.456 = version 1, release 23, modifica...
Is there a canonical ordering of submatch expressions in a regular
expression?
For example: What is the order of the submatches in
"(([0-9]{3}).([0-9]{3}).([0-9]{3}).([0-9]{3}))\s+([A-Z]+)" ?
a. (([0-9]{3})\.([0-9]{3})\.([0-9]{3})\.([0-9]{3}))\s+([A-Z]+)
(([0-9]{3})\.([0-9]{3})\.([0-9]{3})\.([0-9]{3}))
([A-Z]+)
([0-9]{3...
I need to write a function that receives a string and a regex. I need to check if there is a match and return the start and end location of a match. (the regex was already compiled by qr//)
The function might also receive a "global" flag and then I need to return the (start,end) pairs of all the matches.
ps. I cannot change the regex ...
I am trying to validate user id's matching the example:
smith.jack or smith.jack.s
In other words, any number of non-whitespace characters (except dot), followed by exactly one dot, followed by any number of non-whitespace characters (except dot), optionally followed by exactly one dot followed by any number of non-whitespace characte...
Does anyone know if it's possible to use regex capture within Apache's DirectoryMatch directive? I'd like to do something like the following:
<DirectoryMatch ^/home/www/(.*)>
AuthType Basic
AuthName $1
AuthUserFile /etc/apache2/svn.passwd
Require group $1 admin
</DirectoryMatch>
but so far I've had no success.
Specifi...
I've used RegexBuddy several times and found it to be a really useful tool. Is there anything like it in the open source world, preferably something that is platform agnostic? (the fact that regexbuddy is windows only is a real downer)
The only thing I've been able to find is Kodos, which I've also used quite a lot, but it doesn't quit...
I know how to do this if I iterate through all of the characters in the string but I am looking for a more elegant method.
Thanks
...
Ok, so i'm working on a regular expression to search out all the header information in a site.
I've compiled the regular expression:
regex = re.compile(r'''
<h[0-9]>\s?
(<a[ ]href="[A-Za-z0-9.]*">)?\s?
[A-Za-z0-9.,:'"=/?;\s]*\s?
[A-Za-z0-9.,:'"=/?;\s]?
''', re.X)
when i run this in python reg ex. tester, it works out...
I'm trying to match elements with a name that is 'container1$container2$chkChecked', using a regex of '.+\$chkChecked', but I'm not getting the matches I expect when the element name is as described. What am I doing wrong?
...
How can I take the string “foo[]=1&foo[]=5&foo[]=2” and return a collection with the values 1,5,2 in that order. I am looking for an answer using regex in C#. Thanks
...
I have a string which contain tags in the form < tag >. Is there an easy way for me to programmatically replace instances of these tags with special ascii characters? e.g. replace a tag like "< tab >" with the ascii equivelent of '/t'?
...
In other words may one use /<tag[^>]*>.*?<\/tag>/ regex to match the tag html element which does not contain nested tag elements?
For example (lt.html):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>greater than sign in attribute value</title>
</head>
<body>...
Most of my users have email addresses associated with their profile in /etc/passwd. They are always in the 5th field, which I can grab, but they appear at different places within a comma-separated list in the 5th field.
Can somebody give me a regex to grab just the email address (delimeted by commas) from a line in this file? (I will b...
Pretty basic question, I'm trying to write a regex in Vim to match any phrase starting with "abc " directly followed by anything other than "defg".
I've used "[^defg]" to match any single character other than d, e, f or g.
My first instinct was to try /abc [^\(defg\)] or /abc [^\<defg\>] but neither one of those works.
...
I have the following string:
cn=abcd,cn=groups,dc=domain,dc=com
Can a regular expression be used here to extract the string after the first "cn=" and before the first ","? In the example above the answer would be "abcd".
Thanks.
...
Suppose you have the following string:
white sand, tall waves, warm sun
It's easy to write a regular expression that will match the delimiters, which the Java String.split() method can use to give you an array containing the tokens "white sand", "tall waves" and "warm sun":
\s*,\s*
Now say you have this string:
white sand and tall...