regex

Why is this sed RegEx expression chopping off digits in certain circumstances?

sed -e 's/ *-\{0,1\},\{0,1\} *[Pp][Aa]\{0,1\}[Rr]\{0,1\}[Tt].\{0,1\} *\([0-9]\{1,\}\) *$/ (\1)/' I'm piping titles through this from an iTunes AppleScript. This should convert any title with a Part designation at the end to a parenthetical format For instance, Best of Both Worlds, Part 2 becomes Best of Both Worlds (2). The trouble r...

How to Validate special characters in a textbox and show entered special characters in the error message?

There is a textbox and a button that validates the entry inside the textbox. That if it should not validate the presence of illegal characters in the form. Suppose I entered the following word "Lorem# %ipsum^" On clicking the button, two things should happen If there sre any special chars like #$%^&, then the form submission shoul...

Regex to find a file in folder

Hi How to find all files matches a regex pattern in a folder? Thanks ...

How to match patterns in with regular expressions

Hello, i want to to validate a string if contains only a-z, 0-9, and the symbols . - _ @ and ; i have this code: var regex = new RegExp('[a-z0-9@.;_-]{8,}'); and is not far from what i am looking for but it return true also for: '[email protected] °%' I'm working with jquery to load the string by a div, i put a some code more: var ...

Perl pattern matching

Hi All, I have a text file like this this is a junk line this is a junk line2 this is a junk line3 message1 this is first line of text this is second line of text this is third line of text this is fourth line of text this is fifth line of text message1_end the next line I want to start pattern match from message1 onwards and then pri...

i modifier doesn't work with foreign languages?

My string is in foreign language, i use the following expression $str = 'մի քանի Բառ ձեր մասին'; $word = 'բառ'; $cont = preg_match_all("/.{0,80}[^\s]*?".preg_quote($word)."[^\s]*?.{0,80}/si",$str,$matched); print_r($matched);//returns Array ( [0] => Array ( ) ) .. . but if i set $word = "Բառ";//returns Array ( [0] => Array ( [0] =...

Identify URLs in a textarea and show them as output using javascript

i have a text area and a click me. In that text area, if a user enters some URLs then the input should be marked invalid on the button click. For example, if my input is "StackOverFlow, the greatest codding buddy you could ever have. The URL: www.stackoverflow.com You can also checkout meta.stackoverflow.com which is also super cool" ...

regex to higlight the word part-by-part if it contain the keyword

i've asked same question before here, but now i need to higlight the keywortd in another way, then other part of word. example will be helpful i think $str = "i like programming very much"; $key = "gram"; i need to get something like pro gram ming $str = "i like <span class='first'>pro</span><span class='second'>gram</span><span cla...

regex in as3 to ignore match with specific start to string

I have the following as3 function below which converts normal html with links so that the links have 'event:' prepended so that I can catch them with a TextEvent listener. protected function convertLinks(str:String):String { var p1:RegExp = /href|HREF="(.[^"]*)"/gs; str = str.replace(p1,'HREF="event:$1"'); return str; } For exam...

Notepad++ Regex Replace doesn't work on Notepad++

I tried to search for every word that has bar-foo and switch them to foo-bar so I wrote on the find (\w+)-(\w+) and on the replace $2-$1 and instead of writing foo-bar it wrote $2-$1. Yes, Regular Expression in search mode is on. It seems that the Replace Regex doesn't work and been taken literally ...

How to prevent illegal characters to appear in my XML when retrieving it from SQL Server

Sometimes the string values of Properties in my Classes become odd. They contain illegal characters and are displayed like this (with boxes): 123[]45[]6789 I'm assuming those are illegal/unrecognized characters. I serialize all my objects to XML and then upload them via Web Service. When I retrieve them again, some characters are re...

How to split a string on * and - in PHP?

Inorder to split the string i have used the following code. $string = "-sev*yes-sev1*no-sev2*yes"; split('[-*]', $string). As split is deprecated, can you please suggest an alternative to split the string into an array. I have tried with explode, but it is not serving my purpose. The output should look like, Array ( [0] => sev ...

Makefile dependencies with regular expression

hi, I have a list of RPM file names (like "package-1.0") that will be the dependencies of a make target, but some of them have the architecture x86_64 and others have i386. what do I do to match them? I need something like: target: $(addsuffix .[i386|x86_64].rpm,$(shell cat packages_file)) but that won't work. I could use: target: $...

How do I disable Eclipse's find/search regex hint drop-down ?

When searching (across files) or finding (within files), if you have regular expressions enabled and enter a certain character (backslash, opening paren, etc) it displays a drop-down box with hints in. I don't need these hints; they get in the way of the rest of the dialog, and the stupid drop-down hijacks my home/end keys. However, I ...

regex remove digits and - in beginning

I'm treating a list of strings, but I want to alter the strings so they don't look ugly to the user. An example list would be 2736162 Magazines 23-2311 Numbers 1-38122 Faces 5-231123 Newspapers 31-31235 Armynews 33-12331 Celebrities 1 33-22113 Celebrities 2 Cars Glasses And what I want is to trim out the beginning so that the ugly seq...

regex to eliminate field in bibtex file

I am trying to slim down the bib text files I get from my reference manager because it leaves extra fields that end up getting mangled when I put it into LaTeX. A characteristic entry that I want to clean up is: @Article{Kholmurodov:2001p113, author = {K Kholmurodov and I Puzynin and W Smith and K Yasuoka and T Ebisuzaki}, journal = {...

An ungreedy regular expression to fetch title from a page

Hello I want to get the title of a web page using C#. So i'm requesting that page and getting the response page and using a regular expression to extract the title. string regex = @"(?<=)([\s\S]*)(?=)/"; But i saw a site having two titles such as <title>Page Title</title> <link href="...."/> <title>Page Title</title> So when i use ...

How do I fix "invalid group" error when attempting to use Gruber's "improved" URL matching regexp pattern in JavaScript?

I'm attempting to integrate John Gruber's An Improved Liberal, Accurate Regex Pattern for Matching URLs into one of my Javascripts, but WebKit's inspector (in Google Chrome 5.0.375.125 for Mac) gives an "Invalid group" regular expression syntax error. Gruber's original regexp is as follows: (?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|ww...

Javascript split regex question

hello I am trying what I thought would be a rather easy regex in Javascript but is giving me lots of trouble. I want the ability to split a date via javascript splitting either by a '-','.','/' and ' '. var date = "02-25-2010"; var myregexp2 = new RegExp("-."); dateArray = date.split(myregexp2); What is the correct regex for this an...

Need to apply double quotes around every value of csv file

I have a csv file that I need EVERY column wrapped in quotes. How do I change that using regex? I am using my text editor to do the find/replace w/ regular expression (textmate) example csv: bear,brown,mean,large ant,black,strong,tiny cat,yellow,moody,small ...