regex

how to add an extra character at end of each line in vim

I have the following use case, my file contents look like this a b c I want a regular expression to do this a| b| c| Can you recommend a regex in vim? ...

C# subtring parse using regular expression (ATL >> NET)?

What is the C# & .NET Regex Pattern that I need to use to get "bar" out of this url? http://www.foo.com/bar/123/abc In ATL regular expressions, the pattern would have been http://www\.foo\.com/{[a-z]+}/123/abc ...

Delimiter in one string

Hello, Here is an example of a file that i use to create a mysql db. The delimiter is "," but in the description for a single column exist ",". Header: City State Zip Description Los Angeles, California , 98005, "welcome to california, were are living the dream","Please stay, a while." The problem is that the description in "quotes"...

I'm looking for an application/text editor that....

can best help me systematically modify the "replace" field of a regex search as it encounters each match. For example, I have an xml file that needs the phrase "id = $number" inserted at regular points in the text, and basically, $number++ each time the regex matches (id = 1, id = 2, etc) until the end of the file. I know I could just ...

How does this regex work and how do i make it repeat only 5 times?

What does this regex do? i know it replaces the filename (but not extension) Regex r = new Regex("(?<!\\.[0-9a-z]*)[0-9]"); return r.Replace(sz, "#"); How do i make it only repeat 5 times? to make it convert "1111111111.000" to "11111#####.000" ? ...

[Java] use of delimiter function from scanner for "abc-def"

Hi! I'm currently trying to filter a text-file which contains words that are separated with a "-". I want to count the words. scanner.useDelimiter(("[.,:;()?!\" \t\n\r]+")); The problem which occurs simply is: words that contain a "-" will get separated and counted for being two words. So just escaping with \- isn't the solution of c...

Compiling C++ Code With Boost's regex_match

Given this code: #include <iostream> #include <vector> #include <fstream> #include <sstream> #include <boost/regex.hpp> using namespace std; using namespace boost; int main ( int arg_count, char *arg_vec[] ) { if (arg_count !=2 ) { cerr << "expected one argument" << endl; return EXIT_FAILURE; } string ...

Case Sensitive Partial Match with Boost's Regex

Dear all, From the following code, I expect to get this output from the corresponding input: Input: FOO Output: Match Input: FOOBAR Output: Match Input: BAR Output: No Match Input: fOOBar Output: No Match But why it gives "No Match" for input FOOBAR? #include <iostream> #include <vector> #include <fstream> #include <sstrea...

Lowercase regex url

Can someone write a regex that can match only lowercase urls that can have a-z letters, 0-9 numbers and -, http:// (https is not required), www. and doesn't have default.aspx? This is a url that regex must match: http://www.somedomain.net/news/148/some-text-to-act-as-news-title.aspx or http://subdomain.somedomain.net/news/148/some-tex...

regex replace

Hello, I know need some help with regex I am not very smart when it comes to figuring this out but I will get there. My question: I need to remove banner sizes from a string, banner sizes can be 486X60 or 49 X 120 How can I use regex to replace this with blank? ...

Logic in a regular expression...

Hi all, I'm putting together some regexps to handle redirecting incoming links from an old site to the equivalent page on the new site. I'm hoping I can handle the following situation in the regexp so I don't have to do it on the back-end: Incoming link: /reservations/inn_details.asp?num=717 Redirected link: /reservations/property-de...

performance issues with finding nth occurence of a character with a regular expression

I have a regex to find the nth occurrence of a character in a string, here's the code: public static int NthIndexOf(this string target, string value, int n) { Match m = Regex.Match(target, "((" + value + ").*?){" + n + "}"); if (m.Success) { return m.Groups[2].Captures[n - 1].Index; } ...

How to form this Regex

Suppose the string is: string item = "t-ewrwerwerwerwer\r-rr\wrjkwlr"; I want to Replace all - except when it is preceded by r. So resut will be string cleanItem = "tewrwerwerwerwer\r-rr\wrjkwlr"' What regular expression can be used? ...

How do I handle every ASCII character (including regex special characters) in a Perl regex?

I have the following code in Perl: if (index ($retval, $_[2]) != -1) { @fs = split ($_[2], $_[1]); $_[2] is the delimiter variable and $_[1] is the string that the delimiter may exist in. ($_[0] is used elsewhere) You may have guessed that this code is in a subroutine by those variable names. Anyway, onto my question, when my del...

Regex to replace characters that Windows doesn't accept in a filename.

I'm trying to build a regular expression that will detect any character that Windows does not accept as part of a file name (are these the same for other OS? I don't know, to be honest). These symbols are: \ / : * ? " | Anyway, this is what I have: [\\/:*?\"<>|] The tester over at http://gskinner.com/RegExr/ shows this to be work...

Can anyone help with this problem I am having with finditer in python?

Hi, I have a somewhat complex regular expression which I'm trying to match against a long string (65,535 characters). I'm looking for multiple occurrences of the re in the string, and so am using finditer. It works, but for some reason it hangs after identifying the first few occurrences. Does anyone know why this might be? Here's the c...

Java script Validation for Email Id

Duplicate of lots of other questions: http://stackoverflow.com/search?q=validate+email Hi, I want to validate emailid by java script. I am using following code. var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/ ; var emailid=document.getElementById("<%=txtEmail.ClientID %>").value; var...

RedirectMatch and Regex Tomfoolery

I'm trying to redirect all requests for /library/ to an external URL except when .pdf files are requested. e.g. www.mysite.com/library/section should redrect to www.externalsite.com but www.mysite.com/library/docs/some_pdf.pdf should serve up the PDF file without a redirect. Here's what I have: RedirectMatch permanent /library/!(.*\.pd...

Regular expression for excluding special characters

Hi, I am having trouble coming up with a regular expression which would essentially black list certain special characters. I need to use this to validate data in input fields (in a Java Web app). We want to allow users to enter any digit, letter (we need to include accented characters, ex. french or german) and some special characters...

How do I parse this Amazon error report with a regular expression?

When you submit a feed of products to Amazon it will return a error report that will contain suggestions for products that were not matched, like so: 18 998 8042 Error "SKU '998'ASIN B0001FSZ6K 'item_name' Merchant value: 'Promax Nutrition Promax Bar - Mocha Blast' Amazon catalog value: 'Promax Bars, Mocha Blast 12 bars'. ASIN B000...