I have a plain text file something like this:
Ford\tTaurus
F-150
F-250
Toyota\tCamry
Corsica
In other words, a two-level hierarchy where the first child is on the same line as the parent, but subsequent children on lines following, distinguished from being a parent by a two-space prefix (\t above represents a literal tab in the ...
how do I find URLs (i.e. www.domain.com) within a document, and put those within anchors: < a href="www.domain.com" >www.domain.com< /a >
html:
Hey dude, check out this link www.google.com and www.yahoo.com!
javascript:
(function(){var text = document.body.innerHTML;/*do replace regex => text*/})();
output:
Hey dude, check out th...
I have a PHP regular expression that has been functioning fairly well to parse some odd legacy client templates until recently when we found an escaped question mark (\?) included in a template expression. I'm not strong enough with my regular expression-fu to wrap my feeble noodle around a negative look ahead or some techno-mumbo-jumbo ...
I have a lines like this
NF419andZNF773 (e=10^-92,).
ZNF571 (e=2 10^-14,)
What's the regex for extracting the results above so that it gives
NF419andZNF773 - 10^-92
ZNF571 - 2 10^-14
I tried this but fail.
$line =~ /(\w+)\s\(e=\s(.*),\)/;
print "$1 - $2\n";
...
I have this file "file.txt" which I want to split into many smaller ones.
This a piece of it:
0 id:2293 7:0.78235 12:0.69205 17:0.79421 21:0.77818 ..
4 id:2293 7:0.78235 8:0.97904 12:0.69205 17:0.31709 ..
1 id:2294 7:0.78235 8:0.90994 17:0.49058 21:0.59326 ..
Each line of the file has an id field which looks like "id:1"...
I want to search key words (keys would be dynamic) and replace them in a certain format. For example:
these data
keys = ["cat", "dog", "mouse"]
text = "Cat dog cat cloud miracle DOG MouSE"
had to be converted to
converted_text = "[Cat](cat) [dog](dog) [cat](cat) cloud miracle [DOG](dog) [MouSE](mouse)"
Here is my code:
keys = "cat...
When i use a file upload i use to check file contenttype with regular expressions... For ex
private bool IsImage(HttpPostedFile file)
{
if (file != null && Regex.IsMatch(file.ContentType, "image/\\S+") &&
file.ContentLength > 0)
{
return true;
}
return false;
}
This returns...
Hello,
I would like to determine a remote page's encoding through detection of the Content-Type header tag
<meta http-equiv="Content-Type" content="text/html; charset=XXXXX" />
if present.
I retrieve the remote page and try to do a regex to find the required setting if present.
I am still learning hence the problem below...
Here is ...
I use this condition to check if the value is alphanumeric values:
$value =~ /^[a-zA-Z0-9]+$/
How can I modify this regex to account for a possible dot . in the value without accepting any other special characters?
...
I have this piece of code:
function func1(text) {
var pattern = /([\s\S]*?)(\<\?(?:attrib |if |else-if |else|end-if|search |for |end-for)[\s\S]*?\?\>)/g;
var result;
while (result = pattern.exec(text)) {
if (some condition) {
throw new Error('failed');
}
...
}
}
This works, unless ...
hi
i'm really not used to the split string method in c# and i was wondering how come there's no split by more than one char function?
and my attempt to try to split this string below using regex has just ended up in frustration.
anybody can help me?
basically i want to split the string below down to
aa**aa**bb**dd^__^a2a**a2a**b2b**dd...
I would like to change the order of names from Last, First to First Last. I don't know the REGEXP and the php syntax for it.
...
I want to split a string like "001A" into "001" and "A"
...
I need to modify this regex
href=\"(.*)\"
which matches this...
href="./pothole_locator_map.aspx?lang=en-gb&lat=53.153977&lng=-3.533306"
To NOT match this...
href="./pothole_locator_map.aspx?lang=en-gb&lat=53.153977&lng=-3.533306&returnurl=AbandonedVehicles.aspx"
Tried this, but with no luck
href=\"(.*)\"(?!&returnurl=Abandoned...
I want to remove ) character from the end of a string through a regex.
E.g If a string is UK(Great Britain) then I want to replace the last ) symbol.
Note:
1). The regex should remove only the last ) symbol, doesn't matter how many ) symbols are present in the string.
...
$('#customerAddress').text().replace(/\xA0/,"").replace(/\s+/," ");
Going after the value in a span (id=customerAddress) and I'd like to reduce all sections of whitespace to a single whitespace. The /\s+/ whould work except this app gets some character 160's between street address and state/zip
What is a better way to write this? this ...
So, I am doing this search in vim:
/\(\(unum\)\|\(player\)=\)\@<!\"1\"
and as expected it does not match lines that have:
player="1"
but matches lines that have:
unum="1"
what am i doing wrong? isn't the atom to be negated all of this: \(\(unum\)\|\(player\)=\)
naturally just doing: /\(\(unum\)\|\(player\)=\) matches unum= or...
I was trying to match files in a directory that had two dots in their name, something like theme.default.properties
I thought the pattern .\\..\\.. should be the required pattern [. matches any character and \. matches a dot] but it matches both oneTwo.txt and theme.default.properties
I tried the following:
[resources/themes has two f...
I run to get some value as score.
score = soup.find('div', attrs={'class' : 'summarycount'})
I run 'print score' to get as follows.
<div class=\"summarycount\">524</div>
I need to extract the number part. I used re module but failed.
m = re.search("[^\d]+(\d+)", score)
TypeError: expected string or buffer
function search in re...
There has always been a confusion with preg_match in php.
I have a string like this:
apsd_01_03s_somedescription
apsd_02_04_somedescription
Can I use preg_match to strip off anything from 3rd underscore including the 3rd underscore.
thanks.
...