Given the following input...
;
; comment
; another comment
;
data
data
I am looking for a regular expression that can be used to strip the blank lines and return only the two lines containing the "data" (but leaving the line breaks intact).
Thanks.
...
I've found a Perl regexp that can check if a string is UTF-8 (the regexp is from w3c site).
$field =~
m/\A(
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byt...
Say I have a regular expression like the fowllowing:
{"(group 1) | (group 2) (group 3) |....( group n)"}
to match an input String object, if it matches successfully, how can I know which group among above n groups is acturally matches this String object?
What I am using is regex lib in java.util.
Thank you guys.
...
Hi,
I have a regular expression that I use to reduce multiple slashes to single slashes. The purpose is to read a url that is previously converted to a human readable link using mod_rewrite in apache, like this :
http://www.website.com/about/me
This works :
$uri = 'about//me';
$uri = preg_replace('#//+#', '/', $uri);
echo $uri; // e...
hello everyone,
i have a string which i want to edit a part of it.
the string is like
"1:5,7:9,13:20,130:510,134:2,"
now all i want to do is remove the first part of those numbers like
"5,9,20,540,2,"
i tried a bunch of combinations but didn't get what i expected.
Regex rx = new Regex("[:]\\d+[,]");
foreach (Match mx in rx.Matc...
What I am trying to do is swap out any object references to YouTube videos, and replace them with their thumbnail reference along with a call to an internal method which passes the YouTube ID.
A sample body text may look like this:
This is a my test This is a my test This is a my test This is a my test This is a my test This is a my te...
Hello,
I am writing a regex to use with the GNU C regex library:
The string is of the form: (text in italics is a description of content)
(NOT a #) start (maybe whitespace) : data
I have written the following code, but it won't match.
regcomp(&start_state, "^[^#][ \\t]*\\(start\\)[ \\t]*[:].*$", REG_EXTENDED);
What do I need t...
I basically want the same functionality of preg_match_all()from PHP in a Python way.
If I have a regex pattern and a string, is there a way to search the string and get back a dictionary of each occurrence of a vowel, along with its position in the string?
Example:
s = "supercalifragilisticexpialidocious"
Would return:
{
'u' : 1,...
In some obscure situations a regular expression like "/^match/" works in the exact oposite way matching a line that is "something else", and the only way to fix it is to put the whole regex inside braces ... "/^(match)/", why is that happening?
...
I have an application which uses a javascript based rules engine. I need a way to convert regular straight quotes into curl (or smart) quotes. It'd be easy to just do a string.replace for ["], only this will only insert one case of the curly quote.
The best way I could think of was replace the first occurrence of a quote with a left...
I'm a regex newbie and need a single expression that:
matches the "an" and the "AN" but not the "and" or "AND" and matches the "o" and the "O" but not the "or" or "OR" in this predicate:
1and(2or3)AND(4OR5)an(6o7)AN(8O9)
Basically I can't figure out how to convert the expression:
var myRegEx = Regex("[0-9 ()]|AND|OR")
into a "ever...
Hi I have a javascript function that checks for signed integer with 0 to 12 length, i also want to see if there are any leading 0's like 0012 should return false.
function sInteger0to12(str) {
str = str.replace(/^\s+|\s+$/g, '');
return /^[-+]?\d{0,12}$/.test(str);
}
any help will be appreciated.
...
I have been using grepWin for general searching of files, and wingrep when I want to do replacements or what-have-you.
GrepWin has an extensive implementation of regular expressions, however doesn't do replacements (as mentioned above).
Wingrep does replacements, however has a severely limited range of regular expression implementation...
I have a string that I need to do multiple search and replaces to remove leading and trailing spaces inside an attribute. The before and after effect is shown here (visually and with a JS example of it working):
http://lloydi.com/x/re/
Now, I need to do the equivalent in C# - replace all references in a string. But I am really stuck. I...
I have a string that may look something like this:
$r = 'Filed under: <a>Group1</a>, <a>Group2</a>';
Here is the regular expression I am using so far:
preg_match_all("/Filed under: (?:<a.*?>([\w|\d|\s]+?)<\/a>)+?/", $r, $matches);
I want the regular expression to inside the () to continue to make matches as designated with the +? a...
I have a grammar defined as follows:
A -> aA*b | empty_string
Is A a regular expression? I'm confused as to how to interpret a BNF grammar.
...
I've gone over other questions from stack overflow with similar ideas but none seem to resemble closely enough what I'm trying to do.
Seems simple, but I'm in a pickle.
I'm trying to replace multiple occurrences of a line break (\n) with only one line break, so people won't be able to submit more than one line break at a time.
Here's wh...
Given an array of strings,
array1 = ["abcdwillbegoneabcccc","cdefwilbegokkkabcdc"]
and another array of strings which consist of patterns e.g. ["abcd","beg[o|p]n","bcc","cdef","h*gxwy"]
the task is to remove substrings that match any of the pattern strings. for example a sample output for this case should be:
["willbegonea","wilbeg...
What I am trying to do: Parse a query for a leading or trailing ? which will result in a search on the rest of the string.
"foobar?" or "?foobar" results in a search.
"foobar" results in some other behavior.
This code works as expected in the interpreter:
>>> import re
>>> print re.match(".+\?\s*$","foobar?")
<_sre.SRE_Match obj...
Hi ,
I tried it on Google but not get proper RE.will someone help me to achieve this :
Phone Number: (Country Code)-(City Code)-(Number)
Mobile Number: (Country Code)-(Number)
obviously that should not take char.
Please help me
...