regex

Splitting a String into Tokens and Storing the Delimiters in Perl

I have a string like this: a b c d I process my string like this: chomp $line; my @tokens = split /\s+/, $line; my @new_tokens; foreach my $token (@tokens) { push @new_tokens, some_complex_function( $token ); } my $new_str = join ' ', @tokens; I'd like to re-join the string with the origi...

Regular Expression issue.

I have an issue regarding the use of the following regular expression: private Regex _regexDecimals = new Regex(@"[^.,0-9]"); when I use above the result is dat I can use 1 0,5 ,5 1.0 but when I enter .5 it results in an error trying it to convert it to a double. Now I've made the following regular expression: private Regex _regex...

jquery anchor to html extract

I would like to implement something similar to the Google quick scroll extension with jquery for the extracts of a search result, so when the full document is opened (within the same website) it gives the user the opportunity to go straight to the extract location. Here is a sample of what I get returned from the search engine when I se...

regex on an array to rename keys

Hay all, i have an array Array ([near_prescription] => Array ( [go_to] => inter_selection [distance_right_sph] => 0.00 [balance_right] => [distance_right_cyl] => 0.00 [distance_right_axis] => [distance_left_sph] => 0.00 [balance_left] => [distance_left_cyl] => 0.00 [distance_left_axis] => ...

regex can't recognize "\n"?

so at the end the end(after few days of debuging) i found a problem. It isnt in regex at all :/ . It seams that i was trimming ekstra white spaces with intput= Regex.Replace(input, "\\s+", " "); so all new lines are replaced with " ". Stupid! Moderator, please remove this if unnecesary! I have regexp for tokenizing some text and it...

javascript regExp compatibility in IE

^(?=[\w-%&?#=]+\d)(?=[\w-%&?#=]+[a-zA-Z])[\w-%&?#=]{8,12}$ Was meant to match the below conditions in a javascript based new-password check, Must contain minimum 8 to 20 characters, mandatorily including one letter and number May include only one of the following special characters: %,&, _, ?, #, =, - Cannot have any spaces With ab...

Regex Replace Case Insensitivty Issue

I am implementing a website search and am trying to highlight the words the user searched for using the below code: data = Regex.Replace(data, Model.SearchCriteria, "<strong>" + Model.SearchCriteria + "</strong>", RegexOptions.IgnoreCase); However if data is "I went North towards Canada" and the user has searched for "north" the resul...

Regex to validate the number of pipe delimited items

Hi all, I've got a string which is pipe '|' delimited. I need a regex to validate the number of items, based on the pipe character. So a regex which will do the following: If the max number of items is three: asdfasdf|asdfasdf|asdfasdf = VALID asdfasdf|asdfasdf|asdfasdf|asdfasf = Not Valid Also, this string may be empty. Any help w...

Regex for string enclosed in <*>, C#

Hello there, I am trying to get all strings enclosed in <*> by using following Regex: Regex regex = new Regex(@"\<(?<name>\S+)\>", RegexOptions.IgnoreCase); string name = e.Match.Groups["name"].Value; But in some cases where I have text like : <Vendors><Vtitle/> <VSurname/></Vendors> It's returning two strings instead of four, i....

Email Validation - Regular Expression

Possible Duplicate: What is the best regular expression for validating email addresses? Does anyone have a good email regular expression? I'm writing in .NET 2.0 if that matters... ...

Regular Expression to fetch vertical offset from CSS

I have been fiddling with this for almost an hour and am getting nowhere. Regexes are not my strong suit. I have data like the following: .cke_button_about .cke_icon { background-position: 0 -76px; } .cke_button_maximize .cke_icon { background-position: 0 -108px; } I need to replace the vertical values (-76px and -108px) using preg_r...

Begin each new line with a character (unless it already begins with that character) in Notepad++.

Hello all, I've got some configuration files with hundreds of lines of data each. I'd like to begin each line (after the carriage return) with a pound sign ('#') unless it's already beginning with a pound sign. I don't want to do a find+replace because I've got other commented parts of the file that aren't the beginning of a line. So...

Codeigniter Routes for filename with extension

I am using codeigniter and its routes system successfully with some lovely regexp, however I have come unstuck on what should be an easy peasy thing in the system. I want to include a bunch of search engine related files (for Google webmaster etc.) plus the robots.txt file, all in a controller. So, I have create the controller and upda...

regex for removing curly brackets with nested curly brackets

This is my string: "This Is {{ dsfdf {{dsfsd}} ewrwrewr }} My Result". I want to remove the outer curly brackets with their content. The result should be "This Is My Result". This is my best shot at the moment: Text = Regex.Replace(Text, "{{([^}]*)}}", String.Empty); but it doesn't work well. I get "This Is ewrwrewr }} My Text" P...

Regular expression libraries for Mac OS X 10.6

Is there a library compatible with PCRE that can be used on Mac OS X 10.6, and which is Unicode compatible? I was thinking to use the predicates, but it is a little excessive when the application is not already using Spotlight predicates. ...

splitting sentences using regex

Hi! i would like to split a text (using a regex) to a dot followed by a whitespace or a dot followed by new line (\n) i'm working with c# .Net Appreciate your answers! ...

Need C# regexp for URL validation

How to validate by a single regular expression the urls: http://83.222.4.42:8880/listen.pls http://www.my_site.com/listen.pls http://www.my.site.com/listen.pls to be true? I see that I formulated the question not exactly :(, sorry my mistake. The idea is that I want to validate with the help of regexp valid urls, let it be an externa...

PHP Regex - Different parsing on 2 servers

Hi! I have a problem that I haven't seen before. The same regex is producing two different results on two different servers. This is the code: preg_replace('#[^\pL0-9_@-]#iu', '', '!%&abc123_æøå'); Result on server A (php 5.2.6, Server Api: Apache 2.0 Handler): abc123_æøå Result on server B (php 5.2.5, Server Api: CGI/FastCGI): 1...

regular expression replace

why this regex not work? i want to replace my string by all not default charaacters legal are = a-Za-z0-9- rest should be replaced and return without the forbidden chars protected string FormatToInvalidChars(string InputString) { string RegexPattern = @"(^[A-Za-z0-9]*)$"; string s = Regex.Replace(InputString....

C# how to write Regular Expression

My file has certain data like:: /Pages 2 0 R/Type /Catalog/AcroForm /Count 1 /Kids [3 0 R]/Type /Pages /Filter /FlateDecode/Length 84 What is the regular expression to get this output.. Pages Type Catalog AcroForm Count Kids Type Pages Filter FlateDecode Length I want to fetch string after '/' & before 2nd '/' or spac...