regex

Apache FilesMatch - matching a folder in the regular expression

Hi, I'm trying to cache some files using a .htaccess file for Apache2. I want to cache a particular folder longer than anything else, so i've been trying to use the FilesMatch directive like this: <FilesMatch "skins(.*)\.(jpg|png|gif)"> ExpiresDefault A2592000 </FilesMatch> I'm hoping to be able to cache all image files in ...

Collaborative RegEx Development

I'm looking for Collaborative RegEx website or software, where one can submit several cases of "match" and "shouldn't match" then other might refactor the regex. Like refactormycode.com but with a RegEx twist. And this way it's possible to see which code performs faster and is actually correct based on the given match tests. This can be...

str_replace

Hi folks! Current code only replace the spaces to dash (-) $url = str_replace(' ','-',$url); I want only letters, numbers and dash (-) allowed on the URL. Let me know the tricks. ...

Hidden Features of RegEx

Continuing the tradition of 'the great hidden features threads seen here' Show us your best / coolest / craziest / "usefulest" RegEx EDIT: It was foolish of me to not be more specific. My intent was to focus on the lesser known or esoteric features of RegEx implementations in any language. For example, .NET supports a variant of name...

c# problem with regex

hi , i wrote simple program for getting info from web string loginName = null; Regex rloginName = new Regex(@" <tr><td dir='rtl'><h1>(.*?)</h1><br /></td></tr> <!--.............. Titel der Referat ..............-->"); Match mloginName = rloginName.Match(source); if (mloginName.Success) { ...

Combine Regexp

After collecting user input for various conditions like Starts with : /(^@)/ Ends with : /(@$)/ Contains : /@/ Doesn't contains To make single regex if user enter multiple conditions, I combine them with "|" so if 1 and 2 given it become /(^@)|(@$)/ This method works so far but, I'm not able to determine correctly, What should be r...

extract text from mht

I have an mht file, I wish to get all the text of the mht. I tought about using regex, but I have other languages in the mht except english, so the text itself contains stuff like A7=A98=D6... select all the text of a file viewed in your browser, and then copy and paste it into a notepad - this is what i need. Thanks. ...

How do I extract this string using a regular expression in Java?

errorString="AxisFault\n faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException\n faultSubcode: \n faultString: My Error\n faultActor: \n faultNode: \n faultDetail: \n {}string: this is the fault detail" Pattern pattern = Pattern.compile(".*faultString(.*)", Pattern.DOTALL); Matcher matcher = pattern.ma...

How do I remove "http://" from a string in actionscript?

This one may seem basic but I don't know how to do it - anybody else? I have a string that looks like this: private var url:String = "http://subdomain"; What regex do I need so I can do this: url.replace(regex,""); and wind up with this? trace(url); // subdomain Or is there an even better way to do it? ...

Wrap all <img>'s in <div>, take the alt attribute and add it into a <p> inside

Trying to replace this jquery code with some php server side magic: $(document).ready(function() { $('#text img').each(function(){ source = $(this).attr('src'); $(this).wrap($('<div class="caption '+ $(this).attr('class') + '"></div>')).removeAttr('class').removeAttr('height').removeAttr('width'); $(this).after('<p>'...

Converting user input string to regular expression

I am designing a regular expression tester in html and javascript. The user will enter a regex, a string, and choose the function they want to test with (eg search, match, replace, etc. ) via radio button and the program will display the results when that function is run with the specified arguments. Naturally there will be extra text bo...

Perl: extracting data from text using regex

I am using Perl to do text processing with regex. I have no control over the input. I have shown some examples of the input below. As you can see the items B and C can be in the string n times with different values. I need to get all the values as back reference. Or if you know of a different way i am all ears. I am trying to use bran...

Regex for tree structures?

Are there regular expression equivalents for searching and modifying tree structures? Concise mini-languages (like perl regex) are what I am looking for. Here is an example that might clarify what I am looking for. <root> <node name="1"> subtrees .... </node> <node name="2"> <node name="2.1"> data </node> oth...

How to remove symbols from a string with Python?

I'm a beginner with both Python and RegEx, and I would like to know how to make a string that takes symbols and replaces them with spaces. Any help is great. For example: how much for the maple syrup? $20.99? That's ricidulous!!! into: how much for the maple syrup 20 99 That s ridiculous ...

Vim search and replace by decrementing back-reference?

Given the following text in Vim: [2] [3] [4] I want to perform a search and replace and produce the following: [1] [2] [3] I know how to extract out the numbers using back-reference via search and replace: :%s/\[\(\d\)\]/[\1]/g But now the question is how do you go about decrementing the value of \1. Any ideas? ...

How do I delete a matching line, the line above and the one below it, using sed?

I have the following sequence occurring multiple times in a file: yyyy xxxx zzzz I have a regex that matches xxxx. Whenever there is a match, I want to delete that line, the line before (e.g. yyyy) and the line after it (e.g. zzzz). How can I use sed to do this? ...

Regex for matching lines that do NOT contain a word

i have the following lines: Message:Polarion commit Mon May 18 06:59:37 CEST 2009 Message:Polarion commit Fri May 15 19:39:45 CEST 2009 Message:424-18: use new variable Message:Polarion commit Fri May 15 19:29:10 CEST 2009 Message:Polarion commit Fri May 15 19:27:23 CEST 2009 Message:000-00: do something else Message:Polarion commit Fri...

Java Regex for parsing adventure game config

Can anyone give me a hand with a touch of regex? I'm reading in a list of "locations" for a simple text adventure (those so popular back in the day). However, I'm unsure as to how to obtain the input. The locations all follow the format: <location_name>, [<item>] [direction, location_name] Such as: Albus Square, Flowers, Traffi...

regular expression (javascript) How to match anything beween two tags any number of times

I'm trying to find all occurrences of items in HTML page that are in between <nobr> and </nobr> tags. EDIT:(nobr is an example. I need to find content between random strings, not always tags) I tried this var match = /<nobr>(.*?)<\/nobr>/img.exec(document.documentElement.innerHTML); alert (match); But it gives only one occurrence. +...

Checking String for illegal characters using regular expression

Dear all. I want to check a for any illegal character using the following regular expression in PHP. Essentially, I want to allow only alphanumeric and underscore (_). Unfortunately the follow piece of code does not seem to work properly. It should return true if there is any illegal character in the string $username. However, it st...