i have a string that maybe contains text with links.
I use these instructions for elaborate it:
message = message.gsub(/http[s]?:\/\/[^\s]+/) do |m|
replace_url(m)
end
if the string is "http://www.youtube.com/watch?v=6zToqLlM8ms&playnext_from=TL&videos=qpCvM5Ocr3M&feature=sub"
the instructions works.
b...
Well, there are other ways (hmmm... or rather working ways) to do it, but the question is why does this one fail?
/
\A # start of the string
( # group 1
(?: # group 2
[^()]* # something other than parentheses (greedy)
| # or
\( (?1) \) # parenthesized group 1
) ...
$data = "<Data>hello</Data>";
preg_match_all("/\<Data\>[.]+\<\/Data\>/", $data, $match);
print_r($match);
This returns:
Array ( [0] => Array ( ) )
So I am guessing that a match is not made?
...
There are some features in modern regex engines which allow you to match languages that couldn't be matched without that feature. For example the following regex using back references matches the language of all strings that consist of a word that repeats itself: (.+)\1. This language is not regular and can't be matched by a regex, which...
I am fairly new to regular expressions and the more and more I use them, the more I like them. I am working on a regular expression that must meet the following conditions:
Must start with an Alpha character
Out of the next three characters, at least one must be an Alpha character.
Anything after the first four characters is an automa...
Here is the input data:
*** INVOICE ***
THE BIKE SHOP
1 NEW ROAD, TOWNVILLE,
SOMEWHERE, UK, AB1 2CD
...
I have text in the follwing format:
ERR_OUT_OF_MEM, "ERR OUT OF MEM"
ERR_SOMETHING_BAD, "ERR SOMETHING BAD"
I want to replace all spaces in the text which are within quotes with underscores:
ERR_OUT_OF_MEM, "ERR_OUT_OF_MEM"
ERR_SOMETHING_BAD, "ERR_SOMETHING_BAD"
The best regex I could come up with is:
\("\w\+\)\@<=
(there's a...
I have a Expression ($ASMLNA$ * $TSM$ * 8 * ($GrossDownTarget$ * $005930K$)+15)
Now I am trying to get all the variables which is between $ $. Example $ASMLNA$ so for me it should give ASMLNA.
I have tried using RegEx and this is what I have been able to do till now
Regex r = new Regex(@"[^\$]");
string Contents = txtRegEx...
I want to replace every instance of int in a very large codebase with int32_t, for portability reasons. I have unsuccessfully tried :
sed s/'\bint\b'/' int32_t '/g
and it fails to match instances where the int is the first thing on the line. I am completely at a loss for how to make it match then.
Any ideas?
...
Because I have lines like
space space **da ta** tab tab **data**
tab **data** tab tab tab tab **da ta**
I want the above to turn into
**da ta**,**data**
**data**,**da ta**
I need regex to remove all the white space before the first letter and replace the rest with commas... but still ignoring the white space in between the letters ...
I need a regular expression and a way to extract email address from a html page.
code sample needs to be in python
...
Hey
I'm having hard time selecting from a file using a regular expression. I'm trying to replace a specific text in the file which is full of lines like this.
/home/user/test2/data/train/train38.wav /home/user/test2/data/train/train38.mfc
I'm trying to replace the bolded text. The problem is the i don't know how to select only the bol...
I have a possibly large block of text to search for instances of [[...]], where the ... can be anything, including other brackets (though they cannot be nested; the first instance of ]] after [[ ends the match).
I can think of two ways to match this text:
Using a non-greedy qualifier: /\[\[.+?\]\]/
Using a lookahead: /\[\[(?:(?!\]\])....
Hello,
I need some help with writing a regex validation to check for a specific value
here is what I have but it don't work
Regex exists = new Regex(@"MyWebPage.aspx");
Match m = exists.Match(pageUrl);
if(m)
{
//perform some action
}
So I basically want to know when variable pageUrl will contains value MyWebPage.aspx
also if possib...
Can anyone explain:
Why the two patterns used below give different results? (answered below)
Why the 2nd example gives a group count of 1 but says the start
and end of group 1 is -1?
public void testGroups() throws Exception
{
String TEST_STRING = "After Yes is group 1 End";
{
Pattern p;
Matcher m;
String pattern="(?:Y...
Looking for a reg ex to null (empty) the string if it any contains the bad word..
$string1 = "Ihatestackoverflow";
$string2 = "I HaTe sackoverflow";
$string3 = "1HaTestackoverflow";
$badword = "hate";
# result
# string1 = "";
# string2 = "";
# string3 = "";
...
Is there a canonical function/method for escaping a string to be used in a preg_, such that any special PCRE characters will be interpreted as literal. Basically, a know way to ensure that something like
I am a fancy string (well, that guy ... said I was fancy)
is transformed into
I am a fancy string \(well, that guy \.\.\. said I ...
I'm having trouble getting my C# Regex working for C++. In C# I have:
//using System.Text.RegularExpressions;
Regex YourName = new Regex("?<name>\w{3,16}");
but in C++ this does not correctly match:
//using namespace System::Text::RegularExpressions;
Regex^ rx = gcnew Regex("?<name>\w{3,16}", static_cast<RegexOptions>(RegexOption...
I am trying to use Regex in C# to match a section in an xml document and wrap that section inside of a tag.
For example, I have this section:
<intro>
<p>this is the first section of content</p>
<p> this is another</p>
</intro>
and I want it to look like this:
<intro>
<bodyText>
<p> this is asdf</p>
<p> yada y...
Possible Duplicate:
Substitute multiple whitespace with single whitespace in Python
trying to figure out how to write a regex that given the string:
"hi this is a test"
I can turn it into
"hi this is a test"
where the whitespace is normalized to just one space
any ideas? thanks so much
...