I have a string that contains normal characters, white charsets and newline characters between and . This regular expression doesn't work: /<div>(.*)<\/div>. It is because .* doesn't match newline characters. My question is, how to do this?
...
lets say the string is <title>xyz</title>
I want to extract the xyz out of the string.
I used:
Pattern titlePattern = Pattern.compile("<title>\\s*(.+?)\\s*</title>");
Matcher titleMatcher = titlePattern.matcher(line);
String title=titleMatcher.group(1));
but I am getting an error for titlePattern.matcher(line);
...
How do I rewrite this new way to recognise addresses to work in Python?
\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))
...
For example, I have the following string:
var string = 'watch this video http://vimeo.com/8122132 and then see this picture http://www.flickr.com/photos/pmorgan/32606683/';
I wish to find all the valid URLs and place them in an array, done in JavaScript (and jQuery), so in this case:
url[0] = http://vimeo.com/8122132
url[1] = http://...
Is it possilbe to work with Russian characters, in javascript's regex?
Maybe the use of \p{Cyrillic}?
If yes, please provide a basic example of usage.
The example:
var str1 = "абв прв фву";
var regexp = new RegExp("[вф]\\b", "g");
alert(str1.replace(regexp, "X"));
I expect to get: абX прX
...
Test string:
Organic whole wheat bread, Monterey Jack Cheese (milk, cheese culture, salt), Hormel Natural Ham (salt, turbinado sugar, lactic acid (not from milk)
Desired output:
Array (
[0] => Organic whole wheat bread
[1] => Monterey Jack Cheese
[2] => Hormel Natural Ham
)
I don't mind if the sub-in...
I'm using MagpieRSS to parse a Craigslist feed. The "title" field is:
***BUYING ALL BRAND NEW BLACKBERRY IN ANY QUANTITY BOLD~JAVELLIN~ONYX
(Gramercy) $100000
and I'm using
if( preg_match( "/\(*\)*\d+$/", $title, $matches ) )
to figure out the price. $matches[0] should have the price, if I'm not mistaken. However, when I put ...
Hello!
i really like Regex, unfortantly Im not that good at it yet. So therfore I hope you guys can help me out.
The text string I want to validate consists of what I call "segments". A single segment might look like this:
[A-Z,S,3]
So far I managed to build this regex pattern
(?:\[(?<segment>[^,\]\[}' ]+?,[S|D],\d{1})\])+?
it w...
The sample string:
this!is.an?example
I want to match: this is an example.
I tried this:
<script type="text/javascript">
var string="this!is.an?example";
var pattern=/^\W/g;
alert(string.match(pattern));
</script>
...
I'm trying to get some information from a web site. The information I want is in a table so I made a regex but I don't know the right way to simplify it.
The following are two parts of my regex that I would like to simplify:
<br>(.*)<br>(.*)<br>(.*)
<tr><td>(.+)r>(.+)r>(.+)r>(.+).+</td></tr> # This part should be repeated n times(n = ...
I'd like to use grep to find out if/where an html class is used across a bunch of files. The regex pattern should find not only <p class="foo"> but also <p class="foo bar foo-bar">.
So far I'm able to find class="foo" with this example below, can't make it work with multiple classnames:
grep -Ern "class=\"result+(\"| )" *
Any sugges...
On a phpBB forum, memberlist.php lists all the members of the board with the following HTML:
<a href="profile.php?mode=viewprofile&u=4">Username</a>
Where u=4 is the UserID of the user, and Username is obviously their username.
There are probably 50-100 peices of HTML like this and I would like to match them all, so I was going t...
I have a string that looks like:
www.blah.com/asdf/asdf/asdfasedf/123
The string may have a slash followed by numbers, like /123 in the above example.
I want to extract the 123 from the string if it is present.
What would my regex be?
...
so my urls will look like:
/hello-world/blah/
/hello-world/blah
/hello-world/blah/234
/hello-world/234
IF the url has a trailing slash followed by numbers, I need to return the same string but with the slash and numbers removed.
so the last 2 lines should now look like:
/hello-world/blah
/hello-world
How can I get everything BUT t...
Hello all,
I am trying to match a pattern so that I can retrieve a string from a website. Here is the string in Question:
<a title="Posts by ivek dhwWaVa"
href="http://www.example.com/author/ivek/"
rel="nofollow">ivek</a>
I am trying to match the string "ivek" in between the a tag and I want to do this for each post and relate it to ...
A table contains the string "Hello world!"
Thinking of * as the ordinary wildcard character, how can I write a REGEXP that will evalute to true for 'W*rld!' but false for 'H*rld!' since H is part of another word. 'W*rld' should evalute to false as well because of the trailing '!'
...
How can I use a regular expression to match text that is between two strings, where those two strings are themselves enclosed two other strings, with any amount of text between the inner and outer enclosing strings?
For example, I have this text:
outer-start some text inner-start text-that-i-want inner-end some more text outer-end
...
Hi, I am a C# developer, I have been looking at regular expressions (regex) and wanted to know if anyone knows about useful tools for building regular expressions - like a regex query builder?
...
I would like to extract text from an html document keeping the links inside it. for example:
From this HTML code
<div class="CssClass21">bla1 bla1 bla1 <a href="http://www.ibrii.com">go to ibrii</a> bla2 bla2 bla2 <img src="http://www.contoso.com/hello.jpg"> <span class="cssClass34">hello hello</span>
I would like to extract ju...
I have the following which replace all of å, ø, æ .... etc to just _.
$string = strtolower($string);
$regexp = '/( |å|ø|æ|Å|Ø|Æ|Ã¥|ø|æ|Ã…|Ø|Æ)/iU';
$replace_char = '_';
$data = preg_replace($regexp, $replace_char, $string);
Now I want to change them to according to the followings.
Replace,
space to _
å, Å, Ã¥ and Ã… to a,
ø,...