regex

Javascript regular expressions

Hey, Having a small problem for a quick "Search and Highlight" script that I'm working on. I'm using regular expressions because I'd like to do the searching all on client side, after the document has loaded. My search/highlight function goes like this: function highlight(word, colour, container) { var regex = new RegExp("(>[^<]*?)...

Vim: Align second set of opening quotes using Tabular

I've been using the excellent Tabular plugin in Vim to align things, but there's an alignment I want to do pretty commonly that I can't figure out the right regex for. I want this gem 'fakeweb' gem 'factory_girl', '~> 1.3' gem 'factory_girl_rails', '>= 1.0' gem 'rspec', '>= 2.0' gem 'rspec-rails', '>= 2.0' to turn into this gem 'fa...

How can i select some id with xx-xxx-xx-x format?

I need to change below data A320-ZL-522-01-1(2) A320-ZL-531-01-1(1) A320-ZL-531-01-1(2) A320-ZL-531-01-1(1) A320-ZL-531-01-1(2) to ZL-522-01-1 ZL-531-01-1 ZL-531-01-1 ZL-531-01-1 ZL-531-01-1 Can I do it with LINQ using RegEx? public class MatchCTallyToCross { public List<string> Get(string CustomerNumber) { IEngMan...

Multi-Line Regular Expression

I'm trying to match out of this text: <a href="http://english317.ning.com/profiles/blogs/bad-business-writing-487"&gt;Continue&lt;/a&gt; </div> <p class="small"> Added by <a href="/profile/KemberleyRamirez">Kemberley Ramirez</a> on...

Match Numbers in HTML content (not in tag attributes) with REGEX in PHP

Hi All; I have a problem! I wanna detect any numbers in HTML content without numbers in tag attributes, I wanna change this numbers to other character then only numbers not in HTML TAG ATTRIBUTES that match with this REGEX. Example: Hi 3456; <a href="?id=4456">your code: 345</a> Matched 3456, 345 Not Matched 4456 Thanks fr...

Perl Arrays and grep

I think its more a charachters, anyway, I have a text file, consisted of something like that: COMPANY NAME City Addresss, Address number Email phone number and so on... (it repeats itself, but with different data...), lets assume thing text is now in $strting variable. I want to have an array (@row), for exa...

PHP: preg_replace help

Hello, I have the following code: $string = '[url]http://google.com[/url]'; $bbreplace = array ('/\[url\](.+?)\[\/url\]/'); $bbreplacements = array ('<a href=\"\\1\">\\1</a>'); $string = preg_replace($bbreplace, $bbreplacements, $string); print $string; Which creates a url called http://google.com/ that points to mydomain.com/"http:...

How can I express such requirement using Java regular expression?

I need to check that a file contains some amounts that match a specific format: between 1 and 15 characters (numbers or ",") may contains at most one "," separator for decimals must at least have one number before the separator this amount is supposed to be in the middle of a string, bounded by alphabetical characters (but we have to e...

How do I select a regex match from a text/varchar in MS SQL?

I need to extract something from a long piece of text across lots of db rows, in a Microsoft SQL Server database. I could write a script to loop through and extract it, but I was hoping there was nice simple way I can do some SQL like: SELECT IpAddress = matchFirst('RegEx',ColName) FROM table WHERE conditions I've looked about but a...

I have a problem with string.match(part) (javascript)

var string = $.trim("How are you ? are you fine ?"); var part = $.trim("How are you ? are you fine ?"); var SearchResult = string.match(part); if (SearchResult != null && part!="") { alert("hello1"); } string = $.trim("How are you ? a"); part = $.trim("How are you ? a"); SearchResult = string.match(part); if (SearchResult != nu...

Does a .NET function exist that lets you pass in a string containing Regular Expressions and then return the possible matches?

Before I look into doing this myself, is there already a function out there that will do this: I want to pass in a string containing text and RegEx markup and then it returns all possible matches it would look for in a string. so the following passed to the method abc|def|xyz Would return 3 strings in an array or collection: abc d...

Extract every nth letter (number)

I have a file with line: name, space and string of zero and one, and I need to extract every 5nth character of the string of zero and one, make a sum of the results and if the sum is not 0 - save the name into the other file. 1rt2 0001000000100000000000001010000100000000010000001000000100010010000000000000 1gh4 0001000000100000000000001...

Rewrite rule to redirect html, but not any other files

I want my htaccess to redirect URL that end on ".html" to the index.php, but not any other files (so images can keep their href and still be displayed) This is how my htaccess looks like now, it works for the HTML redirect, but styles or images are not displayed (because they are also redirected, I guess) Options +FollowSymLinks Rewrit...

How to match a part of an <iframe> tag?

I'm trying to match the highlighted parts of this string: <iframe maybe something here src="http://some.random.url.com/" and the string continues... I need to match the src="" if it's placed inside of an tag. The iframe tag can be placed anywhere in the source. Thanks in advance! :) ...

How would you sanitize the street number out of a postal address using Java?

To ensure data privacy, I have to publish a list of addresses after removing the street numbers. So, for example: 1600 Amphitheatre Parkway, Mountain View, CA needs to be published as Amphitheatre Parkway, Mountain View, CA What's the best way to do this in Java? Does this require regex? ...

what is wrong with this java regex?

final static private Pattern includePattern = Pattern.compile("^\\s+([^\\s]*)"); ... Matcher mtest = includePattern.matcher(" this.txt"); String ftest = mtest.group(1); I get an exception No match found at java.util.regex.Matcher.group(Matcher.java:468) I'm looking for at least 1 space character followed by a captured group of non...

How do I make this regex a valid Java regex?

In an earlier question I asked about sanitizing postal street addresses, one of the respondents recommended this solution: addressString.replace(/^\s*[0-9]+\s*(?=.*$)/,''); which is perhaps a valid regex call but is not valid in Java. I unsuccessfully tried to make this valid Java code by changing it to the following: addressString....

MYSQL and REGEX compare

Hi Guys, I have some problem with REGEXP and MYSQL. How I cant ignore the accent on my string to compare with the regexp value? SELECT ('estágio') REGEXP '(estagio)') AS dados I cant remove the accent from the database. I tried to convert to _bin or utf8_unicode_ci , but with no sucess. Somebody has a tip for do that? tks ! ...

Matching multiple input values in regex

Hi I have the following input values and I was hoping someone could kindly tell me the best way to match all of the "values" (217, 218, 219) -- The html is escaped and that's what I need to match. <input type=\"hidden\" name=\"id\" value=\"217\"\/> <input type=\"hidden\" name=\"id\" value=\"218\"\/> <input type=\"hidden\" name=\"id\"...

What's the difference between tr/// and s/// when using regex in Perl?

I was wondering when one should use s/// over tr/// when working with regular expressions in Perl? ...