I need to find a certain chunk from a group of HTML files and delete it from them all. The files are really hacked up HTML, so instead of parsing it with HtmlAgility pack as I was trying before, I would like to use a simple regex.
the section of html will always look like this:
<CENTER>some constant text <img src=image.jpg> more con...
I am trying to specifically to pad out the /'s in an a tag's text.
1234/1234/ABCDE => 1234 / 1234 / ABCDE
In context; if I have an a tag:
<a href="http://www.domain.com/path/to/page.html">12 34/1234A/BC DEFG</a>
I would like to get:
<a href="http://www.domain.com/path/to/page.html">12 34 / 1234A / BC DEFG</a>
...
What's the correct regex for a plus character (+) as the first argument (i.e. the string to replace) to Java's replaceAll method in the String class? I can't get the syntax right.
...
I currently use 3 different regular expressions in one preg_match, using the or sign | to separate them. This works perfectly. However the first and second regex have the same type of output. e.g. [0] Source Text [1] Number Amount [2] Name - however the last one since it uses a different arrangement of source text results in: [0] Source ...
I'm looking for a regular expression that detects whether or not a string is anything more than a bunch of HTML tags.
So, desired functionality is:
Input -> Output
"<html></html>" -> False
"<html>Hi</html>" -> True
"<a href='google.com'>Click Me</a>" -> True
"hello" -> True
"<bold><italics></bold></italics>" -> False
"" -> Don't ...
Exact Duplicate: http://stackoverflow.com/questions/201323/what-is-the-best-regular-expression-for-validating-email-addresses
What are valid email address characters and patterns and how would you write a regular expression which matches it?
...
How do I write a regex to match any string that doesn't meet a particular pattern? I'm faced with a situation where I have to match an (A and ~B) pattern.
...
Over the years, "regex" pattern matching has been getting more and more powerful to the point where I wonder: is it really just context-sensitive-grammar matching? Is it a variation/extension of context-free-grammar matching? Where is it right now and why don't we just call it that instead of the old, restrictive "regular expression"?
...
I am making an application where I need to verify the syntax of each line which contains a command involving a keyword as the first word.
Also, if the syntax is correct I need to check the type of the variables used in the keywords.
Like if there's a print command:
print "string" < variable < "some another string" //some comments
...
I've got some bad MySQL entries that I need to fix. I'm trying to do so in PHP.
What I've got:
a whole bunch of text with no numbers Entry #: 2439. a whole bunch of text Click here to blah blah blah
What I want:
a whole bunch of text with no numbers Entry #: 2439. a whole bunch of text <BR><A href="somepage.php?entry_no=2439">Click...
Hello.
I have n regexes. On input a string i have to find all the regexes that this string matches against. This is normally an O(n) operation:
SELECT regex FROM regexes WHERE 'string' RLIKE regex
Now I wonder, what's the fastest way to do this ?
Are there database, structures or storage systems that are optimized to do such an operat...
Am trying the following regular expression in python but it returns an error
import re
...
#read a line from a file to variable line
# loking for the pattern 'WORD' in the line ...
m=re.search('(?<=[WORD])\w+',str(line))
m.group(0)
i get the following error:
AttributeError: 'NoneType' object has no attribute 'group'
...
I am a novice with Regex usage in C#.
I want a regex to find the next keyword from a given list but which is not surrounded by the quotes.
e.g.
if i have a code which looks like:
while (t < 10)
{
string s = "get if stmt";
u = GetVal(t, s);
for(;u<8;u++)
...
How do i look for the following pattern using regular expression in python? for the two cases
Am looking for str2 after the "=" sign
Case 1: str1=str2
Case 2: str1 = str2
please note there can be a space or none between the either side of the "=" sign
Mine is like this, but only works for one of the cases!
m=re.search('(?<=str\s\...
I am expecting a String from an application that looks like:
john|COL-DELIM|doe|COL-DELIM|55|ROW-DELIM|george|COL-DELIM|jetson|COL-DELIM|90|ROW-DELIM|
I want to do two things:
1) Verify the string "looks" correct (i.e. does it match a regex)
2) Pull out each "row", then be able to parse each row
The values in between the delimiters ...
I have a text file containing lines of data. I can use the following powershell script to extract the lines I'm interested in:
select-string -path *.txt -pattern "subject=([A-Z\.]+),"
Some example data would be:
blah blah subject=THIS.IS.TEST.DATA, blah blah blah
What I want is to be able to extract just the actual contents of the ...
The following regex should be for Do Dollars Dollar or #do #Dollars or #Dollar but not for Doblabla (which it currently is) etc..
/^@(?P<name>\w+) (?P<amount>\d+) [#]?Do(?:llars?)?/i
How do I change that? So that it no longer matches on Dogfood and Dogs etc...
Update 3: Not Solved Afterall:
/^@(?P<name>\w+) (?P<amount>\d+) [#]?(do(...
I m looking for a way to find and replace large number of text files. For example;
I want to choose;
<li><a href="">Istanbul, TR POS </a></li>
<li><a href="">Ankara, TR POS </a></li>
<li><a href="">Izmir, TR POS </a></li>
WITH;
<li><a href="pos-istanbul-tr.php">Istanbul, TR POS </a></li>
<li><a href="pos-ankara-tr.php">Ankara, TR PO...
I need to find all matches of word which strictly begins with "$" and contains only digits. So I wrote
[$]\d+
which gave me 4 matches for
$10 $10 $20a a$20
so I thought of using word boundaries using \b:
[$]\d+\b
But it again matched
a$20 for me.
I tried
\b[$]\d+\b
but I failed.
I'm looking for saying, ACCEPT ONLY IF THE ...
Hi friends
i was in need of a regex which will return only 25,36,30 for me from
25 10a 36 10b 30
as they are the only pure numbers in the sequence.
I tried this but it did not work for me :
(^|[ ])\d+|($|[ ])
Any suggestions?
...