regex

RegExp - extract value a tag for [python]

How to get value a tag <a> and <b>? Use regular expressions. <a href="/model.xml?hid=90971&amp;modelid=4636873&amp;show-uid=678650012772883921" class="b-offers__name"><b>LG</b> X110</a> Ie I want get LG X110 ...

Validating multiple email addresses in a mailto: link

I want a regex pattern to allow a mailto: link to have multiple email address I tried below pattern: "((href|src)(\\S)*?=(\\S)*?)?(\"|'|)(((mailto:)?(?:[A-Z0-9._-])@(?:[A-Z0-9.-])\\.[A-Z]([,;]\\s*(?:[A-Z0-9._-])@(?:[A-Z0-9.-])\\.[A-Z])*(</a>)?))" example: <a href = mailto:[email protected],[email protected]>mail me</a>; Is this regex pattern...

how to create exclamations for a particular sentence

I would like to create exclamations for a particular sentence using the java API? e.g. It's surprising == Isn't it surprising! e.g. It's cold == Isn't it cold! Are there any vendors or tools which help you generate exclamations, provided you give a sentence (i.e. the left hand side in the above example). Note: The sentences will be p...

Java replaceAll with regular expression

I have a text like this: ...<span>my name is bob and I live in </p><p>America</span>... I would replace this text in ...<span>my name is bob and I live in </span></p><p><span>America</span>... I know the replace() function, but I don't know well regular expressions, how it's possible to do this? Keep in mind that is possible to h...

Regex to match 1234, 1324, 2341 (all permutations of {1,2,3,4})

I am implementing the following problem in ruby. Here's the pattern that I want : 1234, 1324, 1432, 1423, 2341 and so on i.e. the digits in the four digit number should be between [1-4] and should also be non-repetitive. to make you understand in a simple manner I take a two digit pattern and the solution should be : 12, 21 i.e. the...

Split a string according to a regexp in VBScript

Hi, I would like to split a string into an array according to a regular expression similar to what can be done with preg_split in PHP or VBScript Split function but with a regex in place of delimiter. Using VBScript Regexp object, I can execute a regex but it returns the matches (so I get a collection of my splitters... that's not what...

assign matched values from jquery regex match to string variable

I am doing it wrong. I know. I want to assign the matched text that is the result of a regex to a string var. basically the regex is supposed to pull out anything in between two colons so blah:xx:blahdeeblah would result in xx var matchedString= $(current).match('[^.:]+):(.*?):([^.:]+'); alert(matchedString); I am looking to get ...

How to replace all characters in a string using JavaScript for this specific case: replace . by _

The following statement in JavaScript works as expected: var s1 = s2.replace(/ /gi, '_'); //replace all spaces by the character _ However, to replace all occurrences of the character . by the character _, I have: var s1 = s2.replace(/./gi, '_'); But the result is a string entirely filled with the character _ Why and how to replace...

What is this Regex doing: new Regex(@"(?<!\\),");

Regex rx = new Regex(@"(?<!\\\\),"); String test = "OU=James\\, Brown,OU=Test,DC=Internal,DC=Net"; This works perfectly, but I want to understand it. I've been gooling without success. Can somebody give me a word or phrase that I can use to look this up and understand it. I would have thought that it should be written like this: ...

How many substitutions took place in a Perl s///g?

Well, the title says it all. Small example: perl -e '$s="aaabbcc";$c=()=$s=~/a/g;print"$c\n$s\n"' (m//g) outputs 3 aaabbcc whereas perl -e '$s="aaabbcc";$c=()=$s=~s/a/x/g;print"$c\n$s\n"' (s///g) outputs 1 xxxbbcc I'd like to do both things at once without having to match first: substitute and know the number of substitutions. Obv...

How do I match unicode characters in Java

I m trying to match unicode characters in Java. Input String: informa String to match : informátion So far I ve tried this: Pattern p= Pattern.compile("informa[\u0000-\uffff].*", (Pattern.UNICODE_CASE|Pattern.CANON_EQ|Pattern.CASE_INSENSITIVE)); String s = "informátion"; Matcher m = p.matcher(s); if(m.matches()){ ...

Regex to extract a block of text between matches.

Alright, so here's my problem. I'm trying to write a script in PHP that will parse our workorder system and return a set of tickets but I've run into a bit of a snag trying to parse the ticket list. I've been trying to use regex as much as possible to force myself to learn the syntax and I could sware that this should work but alas, it's...

is there a elegant way to parse a word and add spaces before capital letters

i need to parse some data and i want to convert AutomaticTrackingSystem to Automatic Tracking System essentially putting a space before any capital letter (besides the first one of course) ...

Converting anchor tag with relative URL to absolute URL in HTML content using Java

The situation: On server A we want to display content from server B in line on server A. The problem: Some of the hyperlinks in the content on server B are relative to server B which makes them invalid when displayed on server A. Given a block of HTML code that contains anchor tags like the following <a href="/something/somwhere.h...

Sanitize pasted text from MS-Word

Here's my wild and whacky psuedo-code. Anyone know how to make this real? Background: This dynamic content comes from a ckeditor. And a lot of folks paste Microsoft Word content in it. No worries, if I just call the attribute untouched it loads pretty. But the catch is that I want it to be just 125 characters abbreviated. When I add tr...

Help on rule on .htaccess

I have made an .htaccess to my root directory for creating a subdomain level, assume it is sub.domain.ex that redirect to domain.ex/deb/ RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} sub.domain.ex RewriteCond %{REQUEST_URI} !deb/ RewriteRule ^(.*)$ /deb/$1 [L] and this works well. Now, I go to /deb/ and create another .htac...

Is there a book that explain the algorithm used by regular expression functions?

Is there a book that explains the algorithm used by the regular expression functions, and optionally shows an implementation in some high level language? ...

Regex Replace: Match hypen not preceded by slash

How can i replace Hypen's inside a string, but ignore hypens preceded by a slash eg: "Just-Testing-A-String-\--But i want to leave this hypen" ...

Recursive regex in PHP

Possible Duplicate: RegEx match open tags except XHTML self-contained tags Hi to all! Could you please explain to me a little about a recursive regular expression in PHP PCRE? So, for example I have general nested html: <div id="first"> <b>some text</b> <div id="second"> <div id="third"> ... </...

regex for extracting anchor in a url

I'm trying to extract an anchor tag and everything behind it from a url using preg_replace. I found one to remove everything after the #, but I want one that removes the # and everything behind it. http://blah.com#removethis Thanks, Steve ...