regex

Remove all but some special characters

Hey, I am trying to come up with a regex to remove all special characters except some. For example, I have a string: str = "subscripción gustaría♥" I want the output to be "subscripción gustaría". The way I tried to do is, match anything which is not an ascii character (00 - 7F) and not special character I want and replace it with b...

regex to find div tags

I need a regex that will find either an opening div tag, or a closing div tag, or both in an html web page. Thanks :) ...

JAVASCRIPT: Count the number of REGEX results

This is what regex should find { anything in it }, and then I want to count the number of results what the regex found. So I have a string like this: {example1}{example2}{example3} in this case the count number is 3 ...

Regex for clean URLs

Clean URLs seem pretty simple but I'm in need of a special situation. I would like to be able to include the .html suffix or nothing at all but not any other extension: someurl = pass someurl/somepage = pass someurl.html = pass someurl/somepage.html = pass someurl.css = fail someurl.exe = fail someurl.anyotherextension = fail someurl/...

JAVASCRIPT: Make array from regex

I have this string: {example1}{example2}{example3} This is the regular expression to find these { anything in it }: /\{.*?\}/g Now I want to know how put them in an array so I can do a FOR IN statement. EDIT I want an array something like array("{example1}","{example2}","{example3}"); ? ...

Substitute one character in a line only if it occurs before another specific character

I have an instance where certain URLs are getting malformed with equal signs and I need to be able to remove them. An example broken URL: http://www.go=ogle.com/search?ie=UTF to be corrected to this: http://www.google.com/search?ie=UTF It can not simply replace the first occurrence of = because not all URLs are broken like this....

how to do the regexp in javascript for this string?

Hi there: I have the following possible string: '', or '4.', or '*.4' or '4.35' all the above format are valid, others are all invalid. basically, if I don't care the digit or word character, this is what I used in PHP for the validation: else if ( !ereg('^\*|.*\..*$',$bl_objver) ) Now, I would like to add some clientside...

preg_match help

Hi! I'm using preg_match for the first time but I'm stuck even before I got some code... With the help from RegExr I have figured out that I need to use this expression: /\(.*M\)\s.*?:/gm What I need help with is how I gonna use this to place<b></b>around the matched text. Gratefull for help. ...

How do I write a Clojure macro to create a regular expression from a String?

I'm creating a convenience macro. Part of the convenience is that a regular expression can be specified with just a String, rather than the #"re" notation. The one part I can't figure out is how to get the macro to take the String and rewrite it as a Clojure regex (e.g., produce the #"re" notation). I think it's a syntax / escaping prob...

URL routing problem in codeigniter

Hello all I am trying to route a URL using codeigniter URL routing. I want to redirect a url like /users/edit?email to userController/editemail /users/edit?password to userController/editpassword I tried using the following line in routes.php in config folder $route["users/edit?(email|password)"] = "userController/edit$1"; This ...

tinyMCE simple syntax highlighting

I want a simple real-time syntax highlighting in a tinyMce editor. I want to highlight (change background or color of the text) for every #{keyword} and #{more keywords} in the text. Keyword can only contain letters, numbers and dots (.). I don't know if my idea is good: bind to onChange event of the editor remove all occurrences of <s...

Correct grouping with regex

Hello, I have a regex which includes a list of commands. But I don't know what kind of parameter behind it is, so it can be a string or a number or nothing. And there can be the possibility, that I don't know the command. In my first version there wasn't any strings, so (abc|def|[a-z]+)([0-9]*) works fine. But now I want to allow str...

Regular expression match first found value

I have a program-generated HTML file, and this tag is repeating: <table cellspacing="0" cellpadding="0" border="0" id="pt1:pt_region0:0:resId1:5:pgl3"> <table cellspacing="0" cellpadding="0" border="0" id="pt1:pt_region0:0:resId1:4:pgl3"> <table cellspacing="0" cellpadding="0" border="0" id="pt1:pt_region0:0:resId1:3:pgl3"> How do I g...

Regular expression to allow range of numbers, or null

I have the following Regular Expression, how can I modify it to also allow null? [0-9]{5}|[0-9]{10} I would like it to allow a 5 digit number, a 10 digit number, or null Thanks ...

How do I pass function parameters into a regex query?

How would I go about passing function parameters into a regex query? Many thanks. function match(str, arg1, arg2){ var result = str.match(/(arg1 | arg2)/m); log(result) //null } match('claire nick steve', 'nick','steve'); ...

How do I find a HTML div contains specific text after a text prefix?

I have following string: <div> text0 </div> prefix <div> text1 <strong>text2</strong> text3 </div> text4 and want to know wether it contains text3 inside divs that go after prefix: prefix<div>...text3...</div> but I don't know how ta make regex for that, since I can't use [^<]+ because div's can contain strong tag inside. Please he...

python url regexp

Hi all. I have a regexp and i want to add output of regexp to my url for exmaple url = 'blabla.com' r = re.findall(r'<p>(.*?</a>)) r output - /any_string/on/any/server/ but a dont know how to make get-request with regexp output blabla.com/any_string/on/any/server/ ...

how do I match words of specific sizes using Regular Expressions?

I have a file called file.txt with say 3 words ban moon funny Now I want to match only the words with 3 or 4 characters grep "[a-z]\{3,4\}" file.txt This is not working..it stil matches all the 3 words, I was expecting only to match the first 2. What am I doing wrong here? ...

Zend Framework - Regex Routes and Url View Helper Issue

Hi, I have this route setup in one of my bootstrap files... $route = new Zend_Controller_Router_Route_Regex( 'user/(\d+)', array( 'module' => 'user', 'controller' => 'view', 'action' => 'index' ), array( 1 => 'id' ), 'user/%d' ); $router->addRoute('user', $rou...

How get text with preg_match till end of word?

I need to find part of string which is equal to string till end of word. Example i have texts: "Start play. I need..." "Start playstation play" "start play, work" "start player" "start pay with..." Then i searching for "/^start play/'i" and found all phrases, but i need only phrases which ends with word play: 1, 3, 5 preg_match('...