I have an Android application which grabs some data from an external XML source. I've stripped out some HTML from one of the XML elements, but it's in the format:
<p class="x">Some text...</p>
<p>Some more text</p>
<p>Some final text</p>
I want to extract the middle paragraph text, how can I do this? Would a regular expression be the ...
Hi guys, i have this C++ program (actually it's just a snippet) :
#include <iostream>
#include <pcre.h>
#include <string>
using namespace std;
int main(){
string pattern = "<a\\s+href\\s*=\\s*\"([^\"]+)\"",
html = "<html>\n"
"<body>\n"
"<a href=\"example_link_1\"/>\n"
...
In the example below the following regex (".*?") was used to remove all dialogue first.
The next step is to remove all remaining sentences starting with a lower case letter.
Only sentences starting with an upper case letter should remain.
Example:
exclaimed Wade. Indeed, below them were villages, of crude huts made of timber
an...
How can I replace the same text in folder names in linux?
Say I have "Photos_Jun", "Photos_July", "Photos_Aug", etc. whats the simplest way I can rename them like "Photos Jun", "Photos July", etc (basically I want to replace the underscore with a space " ". I have about 200 of these folders.
I was looking at solution: http://stackoverf...
I got a headache looking for this:
How do you use s/// in an expression as opposed to an assignment. To clarify what I mean, I'm looking for a perl equivalent of python's re.sub(...) when used in the following context:
newstring = re.sub('ab', 'cd', oldstring)
The only way I know how to do this in perl so far is:
$oldstring =~ s/ab/c...
I seem to get it to work with the following regexp by preg_match():
@^(?:[1-9][0-9]*)|0$@
Yet it's weird that it matches '-0', considering there are no '-' allowed at all in the regexp. Why?
What's more weird is that if you switch the parts divided by |:
@^0|(?:[1-9][0-9]*)$@
It matches all negative integers such as '-2' and '-10'...
Hi I'm trying to setup a RegexpValidator that only accepts a string of alphanumeric characters between 6-30 characters long and requires one number. I'm new to Regular Expressions and everything I've tried seems to keep returning an invalid ValidationRsultEvent. Here's a chunk of code:
<mx:RegExpValidator id="regexValidator" source="{pa...
Basically I want to strip the document of words between blockquotes. I'm a regular expression newb and even after using rubular, I'm no closer to the answer.
Any help is appreciated.
...
Anyone help? When I run this I get " invalid quantifier ?<=href= "
var aHrefMatch = new RegExp("(?<=href\=")[^]+?(?=")");
var matchedLink = mystring.match(aHrefMatch);
But I know the regular expression is valid.
Any ideas?
...
Hello! I have got the following regular expression working just fine in Rad Software Regular Expression designer.
param\s+name\s*=\s*"movie"\s+value=\s*"(?<target>.*?)"
And now i am wondering, how to get this to work in javascript. It keeps on complaininge about the "target" part. I am trying to validate and get the url from the youtu...
Hello
34|http://v19.lscache8.c.youtube.com/videoplayback?ip=0.0.0.0&sparams=id,expire,ip,ipbits,itag,algorithm,burst,factor,oc:U0dWRlZUVF9FSkNNNl9OTlhF&fexp=902210&algorithm=throttle-factor&itag=34&ipbits=0&burst=40&sver=3&expire=1271696400&key=yt1&signature=583C4A85FA65B6B9782B8B4B5E1F1C08D9EADCA...
Hello,
I am a regex idiot and never found a good tutorial (links welcome, as well as a pointer to an interactive VS2010 integrated editor).
I need to parse strings in the following form:
[a/b]:c/d
a, b: double with "." as possible separator. CAN be empty
c: double with "." as separator
d: integer, positive
I.e. valid strings are:
...
I've seen people here made comments like "regex is too slow!", or "why would you do something so simple using regex!" (and then present a 10+ lines alternative instead), etc.
I haven't really used regex in industrial setting, so I'm curious if there are applications where regex is demonstratably just too slow, AND where a simple non-reg...
I've currenly trying to pull out dates from a file and feed them directly into an array. My regex is working, but I have 6 groups in it, all of which are being added to the array, when I only want the first one.
@dates = (@dates, ($line =~ /((0[1-9]|[12][0-9]|3[01])(\/|\-)(0[1-9]|1[0-2])(\/|\-)([0-9][0-9][0-9][0-9]|[0-9][0-9]))/g ));
...
Hi,
I am looking for a regular expression for c# asp.net 3.5 that will fail if there are ever any double spaces in a sentence or group of words.
the cat chased the dog = true
the cat chased the dog = false (doubles spaces occur at random intervals)
thanks
...
"([\"'])(?:\\\\?+.)*?\\1"
I came up to this regexp to match all quoted strings..
It seems to work great...
The problem is how to match the text that isnt inside quotes..
The inverse -negative somehow...
I read the documentation and
(?!(([\"'])(?:\\\\?+.)*?\\1))
doesnt work
...
I need to parse a string like func1(arg1, arg2); func2(arg3, arg4);. It's not a very complex parsing problem, so I would prefer to avoid resorting to flex/bison or similar utilities.
My first approch was to try to use POSIX C regcomp/regexec or Boost implementation of C++ std::regex. I wrote the following regular expression, which does ...
I have this regex to test for telephone # that should be a toll free.
public static final Pattern patternTollFree = Pattern.compile("^((877)|(800)|(866)|(888))");
So I only want to get those # where the user may have left the 1 off of the front of the string, but I have tried several things and I can't get java to match.
public Strin...
I have a function I use in PHP to work with numbers. The intent is to clean the number and, optionally, convert nulls to zero. It began for me for use in prep for sql, but is now used in more places. Here it is:
function clean_num ($num, $null_to_zero = true) {
$num = preg_replace("/[^-0-9.0-9$]/","",$num);
if (strlen($num) == 0)...
I've been trying to construct a ruby regex which matches trailing spaces - but not indentation placeholders - so I can gsub them out.
I had this /\b[\t ]+$/ and it was working a treat until I realised it only works when the line ends are [a-zA-Z]. :-( So I evolved it into this /(?!^[\t ]+)[\t ]+$/ and it seems like it's getting better,...