I have raw HTML and I need to set all IMG src="http://foo".
This is the RegEx I have so far, and it seems to work. In my environment, it is safe to assume that tags are uppercase and attributes are lowercase. I am doing this in .Net, but I don't think that the platform really matters here. \s is any whitespace in the .Net RegEx engin...
Is there any way to use raw strings in Java (without escape sequences)?
(I'm writing a fair amount of regex code and raw strings would make my code immensely more readable)
I understand that the language does not provide this directly, but is there any way to "simulate" them in any way whatsoever?
...
I'm looking for a way to use the length of a match group in the replace expression with the c# regex.replace function.
That is, what can I replace ??? with in the following example to get the desired output shown below?
Example:
val = Regex.Replace("xxx", @"(?<exes>x{1,6})", "${exes} - ???");
Desired output
X - 3
Note: This i...
I'm running a simpler version of this regex:
<p\s*>(?:&(?:nbsp|\#0*160|x0*A0);|(?:<br\s*/?>)|[\s\u00A0]+)*</p>
On this string:
<p>paste in some bullets from word...</p><p>Firefox:</p><p>Bulleted list test:</p><ul><li>One </li><li>Two <ul><li>Sub item one </li><li>Sub 2 <ul><li>Subsub item1 </li><li>Subsub2</li></ul></li><li>Sub3</li>...
Hello
I have the following code
<?php
$doc = new DOMDocument;
$doc->loadhtml('<html>
<head>
<title>bar , this is an example</title>
</head>
<body>
<h1>latest news</h1>
...
I have a string of digits, ex: "1234", and I need to return the largest matched group of digits for each number in a comma-separated list.
Searching for "1234" in "1000, 1200, 1330, 1235" would return
["1", "12", "1", "123"]
Thanks!
...
In PHP, I use this regex for checking mails:
$rexMail = "/^[a-z0-9\._]+@{1}[a-z0-9-_]+\.{1}[a-z]{2,4}\.?[a-z]{0,2}$/i";
In most cases, this will suffice. However, this mail address turns out to be valid for the regex:
[email protected]
That shouldn't be possible. While multiple points should be allowed before the @ sign, it s...
I am creating a Perl script which will have to process the markup of millions of Wikipedia articles - so speed is an issue.
One of the things I'm looking for are occurrences of templates, which always look like this: {{template}}. Because these can be complicated and nested, I need to find the start and end tags separately, and know th...
The problem is as follows:
There is a massive codebase in Java (hundreds of files in tens of packages) where we need the ability to add and remove the keyword strictfp in each class definition. I am planning to use either sed or awk to perform this substitution. However, I would like to avoid the word "class" in comments or elsewhere fr...
Say I have a text file to parse, which contains some fixed length content:
123jackysee 45678887
456charliewong 32145644
<3><------16------><--8---> # Not part of the data.
The first three characters is ID, then 16 characters user name, then 8 digit phone number.
I would like to write a regular expression to match and verif...
How can I replace the number inside the brackets for any strings not matching the word "Field". So the number inside 'SomethingElse' and 'SomethingMore' could be replaced to a new value, but any bracketed value to the right side of the term 'Field' would not be touched. Note, the word "Field" will always stay the same, so it can be ref...
I want to find doubled-word(s) in a text, i used (\w+) +\1 it works, but however it only finds "abc abc" in the text.
i also want to find "abc def abc def"
thanks,..
...
Hello. I have two simple questions about regular expressions.
Having the string "$10/$50", I want to get the 50, which will always be at the end of the string. So I made: ([\d]*$)
Having the string "50c/70c" I want to get the 70, which will always be at the end of the string(i want it without the c), so I made: ([\d]*)c$
Both seem do ...
I've run into a bit of a problem with a Regex I'm using for humans names.
$rexName = '/^[a-z' -]$/i';
Suppose a user with the name Jürgen wishes to register? Or Böb? That's pretty commonplace in Europe. Is there a special notation for this?
EDIT:, just threw the Jürgen name against a regex creator, and it splits the word up at the ü ...
I'm upgrading a set of web pages to a new system, and I want to strip out and replace the boilerplate at the top of each page, and replace it with new boilerplate. Fortunately, each page has a content table, and no tables before it. I want to do something like:
$contents =~ s/^.*<table/$newHeader/
This only works for the first line of...
I am trying to make the user input exactly 4 characters with no spaces... here's what I have:
.[^\s]{4}
but everything I enter says that it didn't match the regex...
Where am I going wrong?
...
I have the following JavaScript (the spaces in the <P>s are non-breaking):
var html = '...<li>sub 2</li></ol></li></ol>\n\
<p> &n...
I need to get "yomomedia.com" if the HTTP_HOST is [ANY].yomomedia.com except in the cases where it is "dev.yomomedia.com" else it should return dev.yomomedia.com
echo preg_replace("/^([EVERYTHING-OTHER-THAN-DEV])\./Ui","",$_SERVER['SERVER_NAME'])
Just tried the following with no success:
echo preg_replace("/^(?!dev)\./Ui",'','www.yom...
I'd like to test if a regex will match part of a string at a specific index (and only starting at that specific index). For example, given the string "one two 3 4 five", I'd like to know that, at index 8, the regular expression [0-9]+ will match "3". RegularExpression.IsMatch and Match both take a starting index, however they both will...
I have a string of the format: string:num where num is any number but string is a known string that I need to match on. I'd like to have this in an if statement as:
if( it matches 'string:' followed by a number) {
//do something
}
...