regex

How do I replace double quotes with single quotes

Hy everyone how can I replace "" // i think its called double quotes with '' // i think its called single quotes using PHP ? ...

Regular expression to match C's multiline preprocessor statements

Hello, what I need is to match multiline preprocessor's statements such as: #define max(a,b) \ ({ typeof (a) _a = (a); \ typeof (b) _b = (b); \ _a > _b ? _a : _b; }) The point is to match everything between #define and last }), but I still can't figure out how to write the regexp. I need it to make it work i...

replace characters that are enclosed with quotes regexp

How can I replace characters with preg_replace, that are enclosed in quotes. I need to replace all special characters, that are in href="" things. example: <a href="ööbik">ööbik</a> should become <a href="oobik">ööbik</a> ...

Non greedy regex match, JavaScript and ASP

I need to do a non greedy match and hope someone can help me. I have the following, and I am using JavaScript and ASP match(/\href=".*?\/pdf\/.*?\.pdf/) The above match, matches the first start of an href tag. I need it to only match the last href that is part of the /pdf/ folder. any ideas ? ...

How can I replace ?myuser=number with an empty string in PHP

How can I replace a string containing a lot of ?myuser=12122 ?myuser=5457 ... with empty string so that it doesn't show ?myuser=number inside the string? I think I should use regex? ...

help for Url detection regex

I hope this question is not a duplicate but I didn't find anything equivalent on SO. I want a regex for checking an URL. The given URL can be local /some-text or external http://theurl I am trying ^http://|/[-\w/\.]+$ but it doesn't work. I don't know how to write the optional http://. Any help? Thanks ...

Regular expression to retrieve everything before first slash

I need a regular expression to basically get the first part of a string, before the first slash (). For example in the following: C:\MyFolder\MyFile.zip The part I need is "C:" Another example: somebucketname\MyFolder\MyFile.zip I would need "somebucketname" I also need a regular expression to retrieve the "right hand" par...

preg_match_all image source

I have the following regex expression which is to extract the source of any img tag in HTML. /(<img).*(src\s*=\s*"([a-zA-Z0-9\.;:\/\?&=\-_|\r|\n]{1,})")/isxmU However, it doesn't appear to be matching the following: <IMG SRC='http://www.mysite.com/pix/lens/mtf/CAEF8512L.gif'&gt; How can I build it to match this as well? ...

regex replacing text

Hi All, i need a regex to replace a string. <span class=\"Translation\" lang=\"ThisLanguage\"> with this one: <span class=\"Translation\" lang=\"ThisLanguage\" onDblClick=\"window.external.MyFunction(ThisLanguage)\"> there are many languages in this string, each one contains a different "ThisLanguage" anyone knows how it can be d...

How can I match XML tags and attributes with a regular expression in Perl?

What I need is something like this: /<[\w\d]+ ([\w\d]+\=[w\d])+\/>/ Something that would match several attribute key/value pairs. Is that possible? ...

what is Regex pattern for html tag in java or android ?

i have this tag as input tag: <a href="controller.jsp?sid=127490C88DB5&R=35144" class="11-link-dkred-bold"><b>Mr. John Q. Anderson&nbsp;&nbsp;&nbsp;MBA 1977 E</a> in this i want get the value Mr. John Q. Anderson   MBA 1977 E wat is patten value for this in regex? ...

Flex 3 Regular Expression Problem

I've written a url validator for a project I am working on. For my requirements it works great, except when the last part for the url goes longer than 22 characters it breaks. My expression: /((https?):\/\/)([^\s.]+.)+([^\s.]+)(:\d+\/\S+)/i It expects input that looks like "http(s)://hostname:port/location". When I give it the input:...

Match Anything Except a Sub-pattern

I'd like to accomplish what this (invalid I believe) regular expression tries to do: <p><a>([^(<\/a>)]+?)<\/a></p>uniquestring Essentially match anything except a closing anchor tag. Simple non-greedy doesn't help here because `uniquestring' may very well be after another distant closing anchor tag: <p><a>text I don't <tag>want</tag>...

Codeigniter Routes regex

looking for a one line route to route dashed controller and method names to the actual underscored controller and method names. url /controller-name/method-name-which-is-long/ would route to /controller_name/method_name_which_is_long/ see: http://codeigniter.com/forums/viewreply/696690/ which gave me the idea to ask :) ...

Regex for product key

I am trying to do a regex that will show all product keys with the value #####-#####-#####-#####-##### this is the regular expression i have created [A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5} for some reason it just isn't working. ...

My Java regex isn't capturing the group

I'm trying to match the username with a regex. Please don't suggest a split. USERNAME=geo Here's my code: String input = "USERNAME=geo"; Pattern pat = Pattern.compile("USERNAME=(\\w+)"); Matcher mat = pat.matcher(input); if(mat.find()) { System.out.println(mat.group()); } why doesn't it find geo in the g...

Javascript Regular Expression "Single Space Character"

Hello experts, O am learning javascript as I analyze existing codes. In my JS reference book, is searching an single space be "\s"? But I have came across a code obj.match(/Kobe Bryant/); Instead of using \s, it uses the actual space? Doesn't this suppose to generate an error? ...

Using Regex groups in bash

Greetings, I've got a directory with a list of pdfs in it: file1.pdf, file2.pdf, morestuff.pdf ... etc. I want to convert these pdfs to pngs, ie file1.png, file2.png, morestuff.png ... etc. The basic command is, convert from to, But I'm having trouble getting convert to rename to the same file name. The obvious 'I wish it work...

RegEx - How To Insert String Before File Extension

Hi All, How would I insert "_thumb" into files that are being dyanmically generated. For example, I have a site that allows users to upload an image. The script takes the image, optimizes it and saves to file. How would I make it insert the string "_thumb" for the optimized image? I'm currently saving 1 version of the otpimized file. ...

Regular expression in BASH

Hello everyone, I was hoping someone could answer my quick question as I am going nuts! I have recently started learning regular expressions in my Java programming however am a little confused how to get certain features to work correctly directly in BASH. For example, the following code is not working as I think it should. echo 2222 |...