regex

Pulling name value pair from a structured adsense code block contained in a txt file

I have a txt file which contains a google adsense code block and I'm trying to pull in the file via file_get_contents to extract the values of the google_ad_client and google_ad_slot variables. In the examples below, I want to return to my calling function: $google_ad_client = 'pub-1234567890987654'; $google_ad_slot = '1234567890' T...

Javascript regex hangs (using v8)

Im using this regex to get the contents of a tag in a file. var regex = new RegExp("<tag:main>((?:.|\\s)*)</tag:main>"); This causes the v8 engine to hang indefinitely. Now, if I use new RegExp("<tag:main>([\s\S]*)</tag:main>"), all is good. Anyone have an idea why the first one takes too long? ...

Is there equivalent to \Q ... \E in C# Regex

Hello. Is there equivalent to \Q ... \E in C# Regex? I can't find it. Thank you for your help. ...

How to use regex to retrive the content of attribute tag in iphone?

I am new to iphone development.I am using RegexkitLite framework to parse and retrieve the Particular content from the Html source.I want to retrieve the content in the attribute tag.How should i give regex to achieve it.The Tag is <a href="http://www.stackoverflow.com" class="11-link-dkred-bold">This is stack overflow HTML</a> I want...

Matching text on multiple lines which begins and ends with some characters

i have a source file something like String some_words_come_here{ //some string lines //some string lines //some string lines //some string lines }; I am using it in java Pattern.compile("(?m)^Strin.+\\};$", Pattern.MULTILINE | Pattern.DOTALL); but this does not work well with Pattern.compile("(?m)^Strin.+", Patt...

Reg Ex - not allowing zero

Hi, Excuse my ignorance. My knowledge of regular expressions is extremely limited. I have the following regular expression on a regular expression validator. ^(\d{1,3},?(\d{3},?){0,2}\d{3}|\d{1,3})$ It currently allows zero. I need to update it so that it does not allow a value of 0. [Edit: Just to clarify, I would like it to excl...

How do I do this regex in Python?

Suppose I have a string of text, of all characters Latin-based. With punctuation. How do I "find" all the characters and put <strong> tags around it? hay = The fox jumped up the tree. needle = "umpe" In this case, part of the word "jumped" would be highlighted. ...

simple regex match

What would be a regex that matches "nl" OR "fr" (without the quotes) but nothing else, case insensitive? ...

Best way to correct garbled data caused by false encoding

Hi all, I have a set of data that contains garbled text fields because of encoding errors during many import/exports from one database to another. Most of the errors were caused by converting UTF-8 to ISO-8859-1. Strangely enough, the errors are not consistent: the word 'München' appears as 'München' in some place and also as 'MÃœnchen...

Regular expression problem

What is the regular expression for the language 0m1n where m+n is even? ...

Parse a TSV file

Hi, I need to parse a file in TSV format (tab separated values). I use a regex to break down the file into each line, but I cannot find a satisfying one to parse each line. For now I've come up this: (?<g>("[^"]+")+|[^\t]+) But it does not work if an item in the line has more than 2 consecutive double quotes. Here's how the file is ...

How can I execute a bunch of editor commands stored in a file in VIM?

I have read the other posts, e.g., http://stackoverflow.com/questions/1830886/vim-executing-a-list-of-editor-commands and others. The answer isn't clear to me for my case. I have some editor commands that I generated from an SQL query. It uses :s/foo/bar to change country codes (from FIPS to a non-standard code set). Here's a sample of t...

Regex to split up text into 6 columns

This is the text file well a part of it and I want it so I can have it as: Column 1 = distribution Column 2 = votes Column 3 = rank Column 4 = title Column 5 = year Column 6 = Subtitle (but only where there is a subtitle) The regex I'm using is: regexp = "([0-9\\.]+)[ \\t]+([0-9]+)[ \\t]+([0-9\\.]+)[ \\t]+(.*?[ \\t]+\\([0-9]{4...

Look for function calls in a bunch of templates by using a script

Hi all, I have a load of php templates which uses a custom translate function "__", i.e. <?php echo __("Hello"); ?> I need to write a script which will look for all these function calls (there are about 200 templates). I.e. it will find __("Hello") and add it to a sentences to be translated array. For example it will find: $senten...

Regex - Special alpha characters? - Python

I have a list of simple names such as Márquez, because of the á (?< name >[a-zA-Z]+) doesn't seem to be working! Help would be very much appreciated! ...

Regex Expert - PHP Lookaround

Hi all, I am absolutely useless at regular expressions, so i'd appreciate your help. I have a string, such as this: $foo = 'Hello __("How are you") I am __("very good thank you")' I know it's a strange string, but stay with me please :P I need a regex expression that will look for the content between __("Look for content here") and...

Textmate/Regex: Strip whitespace from beginning/end of file

I'm trying to add a macro/command to Textmate for some file cleanup and the last tidbit I haven't figured out is simply to remove blank lines from the beginning and end of a file -- does anyone know how to do this? I know some Textmate or regex trick must exist, just not sure what... ...

parse results in MySQL via REGEX

Hi, I'm a bit confused on the functionality of the REGEX support for MySQL and I have yet to find a solid example on how to separate a result with REGEX within an sql statement. Example: How could I pull data from a table emails that looks something like... +-------------------------+ |Emails | |--------------------...

Regex: How can I get the parameter from function?

Hi there: I am working on getting parameter from a function string. For example, my function is named "translate". So all I need to do is to get everything inbetween "translate(" and ")". Is there a way that i can use regex to do that? So far I have something like: "/translate\((?<keyName>*)\)/i" Unfortunately it's not working. Can a...

Why does a $ in the replacement string passed to the replace() function break some of the time?

I have a variable that I'm using to build a JavaScript function call, and JavaScript's .replace() to surround the line of text with a span and onclick event. The .replace() portion looks like this: code.replace(/(\d{4}\s+)?(LOCAL|PARAMETER|GLOBAL)\s+USING\s+([\S]+)/g, "<span class=\"natprint_popup\" onclick=\"getNaturalCode('" ...