regex

Stripping hex bytes with sed - no match

I have a text file with two non-ascii bytes (0xFF and 0xFE): ??58832520.3,ABC 348384,DEF The hex for this file is: FF FE 35 38 38 33 32 35 32 30 2E 33 2C 41 42 43 0A 33 34 38 33 38 34 2C 44 45 46 It's coincidental that FF and FE happen to be the leading bytes (they exist throughout my file, although seemingly always at the beginnin...

Parsing text file using C#

http://yfrog.com/bftransactionsp Looking for a good way to parse out of this text file, the values highlighted with the yellow boxes using C#. Each section is delineated by a TERM # which I forgot to highlight. Tried this: string fileName = "ATMTerminalTotals.txt"; StreamReader sr = new StreamReader(fileName); string[] delimiter = new ...

Check message for "bad words" and "unseriousness" with php?

Possible Duplicate: How do you implement a good profanity filter? I have a classifieds website, and when displaying a classified, users have the option of mailing a message to the poster of the classified. I need to check this message against bad words and unseirousness before sending it. Firstly, how can I check some text a...

String validation in .NET

String validation .. I want to validate a string contains only the following characters : A-Z 0-9 "/" "-" What's the best way to achieve this. I have tried to use a REGEXP but this is returning valid if any of the characters are valid, not if all of the characters are valid. ...

What is the preferred way to filter a regex search for duplicate matches in C#

A new question has arisen in relation to an earlier question of mine. I have some code that is using a regex to find email addresses. It's working great except that it returns duplicate matches. I searched this site and found a question from a long time ago that was dealing with a similar problem, and the answer had something to do with ...

Is Java RegEx case-insensitive ?

In Java, when doing a replaceAll to look for a regex pattern like: replaceAll("\\?i\\b(\\w+)\\b(\\s+\\1)+\\b", "$1"); (to remove duplicate consecutive case-insensitive words, e.g. Test test), I'm not sure where I put the ?i. I read that it is supposed to be at the beginning, but if I take it out then i catch duplicate consecutive wo...

Stop a regex matching *everything* after what I want to actually match!

Hey! I am quite new to the whole Regex thing and tried to do a preg_match_all in PHP which, kind of the results I wanted but the problem is it matches everything after what I actually wanted... like so: String: This is something <code>Some code here</code> and more Match from Regex: <code>Some code here</code> and more Wanted match fro...

Regex elegant pattern match

Can someone maybe help me with this regex? I am using Javascript and classic ASP. checkxls = checkxls.match(/'.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?';/ig) I need to match this pattern exactly. I am looking for a more elegant way of doing this. ...

Ruby Hpricot RegEx replace <BR>'s with <P>'s

Can someone please tell me how to convert this line of Javascript to Ruby using Hpricot & RegEx? // Replace all doubled-up <BR> tags with <P> tags, and remove fonts. var pattern = new RegExp ("<br/?>[ \r\n\s]*<br/?>", "g"); document.body.innerHTML = document.body.innerHTML.replace(pattern, "</p><p>").replace(/<\/?font[^>]*>/g, ...

Regex pattern match small issue with brackets in pattern match

Hi There Someone helped me earlier with this regex: checkxls = checkxls.match(/'[^']*'(?:, '[^']*'){13};/g); The purpose is to capture a exact patter like this '', '', '', '', '', '', '', '', '', '', '', '', '', ''; Now I want to do the same thing but just with a pattern like this ('.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?',...

Why does this provided regular expression return true?

I would like to know why following regular expression returns true: reg = re.compile (r'[0-9]%') reg.search ("50%") [0-9] would match any single digit, in this case 5. But then 0 doesn't match %, so it should return false, but it returns true. My code might have syntax errors, but you get the gist of it. ...

escaping characters in a regex

The regular expression below: [a-z]+[\\.\\?] Why is \\ slash used twice instead of once? ...

Ignoring whitespace immediately before a character in RegEx

As an exercise in learning RegEx in JavaScript, I've been trying to select an attribute's value within a CSS stylesheet. Given the following CSS: foo { color: rgb(0, 0, 0) !important; background-color: rgb(0, 0, 0) !important; border-left: 1px solid #111; } and a function getStyle(css, attribute) such that getStyle(css, 'b...

how to replace multiple occurrences of `&nbsp; and <br>`

how to replace multiple occurrences of &nbsp; and <br> at start of the string with javascript regex? ...

Javascript validation Problem

In my employee information page, i use the validation in the information page. In that javascript regular expression, var nameRegex = /^[(a-z)(A-Z)\s ]*$/; This nameRegex match with my last and firstname. } else if(!lastname.match(nameRegex)) { For this one, special character are not allowed in last name. It restrict all the spec...

Split by various delimiters, while keeping the delimiter?

I would like to split a text 过公元年?因为无论你如何选择。简体字危及了对古代文学的研究输入! Using on of these three (or more) ?!。 characters as delimiter. i can do this of course with $lines = preg_split('/[。,!,?]/u',$body); However i wan't to have the resulting lines keep their ending delimiter. Also a sentence might end like so 啊。。。 or 什么!??!!!! ...

PHP Regex on URL - split into variables

Hi all, I am trying to implement a php script which will run on every call to my site, look for a certain pattern of URL, then explode the URL and perform a redirect. Basically I want to run this on a new CMS to catch all incoming links from the old CMS, and redirect, based on mapping, say an article id stripped form the URL to the sam...

Elisp: Searching for a string with an unbalanced quote causes Lisp error

search for filename . "myfile.txt" (regexp-quote "filename \. \"\\(.+\\)\"") "filename \\. \"\\\\(\\.\\+\\\\)\"" search for filename . "myfile.txt (without last quote) (regexp-quote "filename \. \"\\(.+\\)") Debugger entered--Lisp error: (invalid-read-syntax ") or . in a vector") read(#<buffer processing-files.el>) preceding-sexp...

Replace Unicode Control Characters, existing solution ?

Hi all, I need to replace all special control character of a string in Java. My need is for ask the google map api V3. And google doesn't seems to like this characters. Example : http://www.google.com/maps/api/geocode/json?sensor=false&amp;address=NEW%20YORK%C2%8F This url contains this character : http://www.fileformat.info/info/uni...

How can I match everything that is after the last occurence of some char in a perl regular expression?

For example, return the part of the string that is after the last x in axxxghdfx445 (should return 445). ...