What do these Perl regexes mean?
What does the following syntax mean in Perl? $line =~ /([^:]+):/; and $line =~ s/([^:]+):/$replace/; ...
What does the following syntax mean in Perl? $line =~ /([^:]+):/; and $line =~ s/([^:]+):/$replace/; ...
How can I remove all characters from a string that are not letters using a JavaScript RegEx? ...
I have a pattern like this that matches multiple sets of values: (((\w+) (\d+))+) I think this would match: one 1 two 2 three 3 four 4 five 5 But because I don't know how many repeats there are I don't know what to put in the output. For instance I need to get the results into something like this: <span class="one">1</span> <span...
Hi, I'm a beginner in regexes. My requirement is to validate simple urls to urls with query strings, square brackets etc.. say for eg, www.test.com?waa=[sample data] the regex that I wrote only work for simple urls. It fails for the one with square brackets. Any idea? ...
This is for a textbox validation. I need to match on a list of domains MATCHES google.com, msn.com, texas.edu.gov.us msn.com NON-MATCHES google.com, msn.com, @msn.com, @google.com [email protected] without the trailing comma (that's where I'm getting stuck) This is what I have so far but the comma delimited part...
I'm dealing with some legacy code that stores its data in a proprietary string format and I'm trying to create a regex to make parsing this format much easier. What I'm having trouble with is the format contains groups that can be repeated many times sporadically. For example typically the data will look liks this (A)(B)(B)(B), but some...
For example, I want to split str = '"a,b,c",d,e,f' into ["a,b,c",'d','e','f'] (i.e. don't split the quoted part) In this case, this can be done with re.findall('".*?"|[^,]+',str) However, if str = '"a,,b,c",d,,f' I want ["a,,b,c",'d','','f'] i.e. I want a behavior that is like python's split function. Is there any way ...
I want to use a regex to find a particular string in my sample, but I want the regex to fail if I first find another string. Let me give an example: Match find_me only if we do not first encounter stop_here. (I don't care if stop_here occurs later in the sample.) So, this should match: blah blah find_me blah stop_here But this shou...
I'm trying to validate a drivers license for a form that i am making. I was trying to use a single regex. Max length 9 characters Alphanumeric characters only Must have at least 4 numeric characters Must have no more than 2 alphabetic characters The third and fourth character must be numeric I'm new at regex I'm googling trying to w...
I want to know is there any way to split text like this: 123456789 into 123-456-789 as to add "-" after every 3 characters? Just wanted to know, as I know the reverse, but how to do this is over my head. ;) and also if the text is ABCDEFGHI OR A1B2C3D4E or any other format without any space between the characters ! languge : PHP...
i'm using a regular expression to search for a bunch of keywords in a text. All keywords are found but one: [DAM]Berlin. I know it contains a square bracket so i escaped it, but still, no luck. What am i doing wrong? here is my php code. The text to search for keywords: $textToSearch= '<p><br> Time ¦ emit LAb[au] <br> <br> [DAM]Berli...
I need to pass an encoded string to a codeigniter controller. Ex: DOSOMETHING/Coldplay/Fix+You/273/X+%26+Y/ My problem is with the percent symbol, has disallowed characters. I tried to change the config file with: $config['permitted_uri_chars'] = 'a-z 0-9~%.:_-+\%'; The + is ok but the % is not valid. Can you help me to change this r...
I have a bunch of files that look like this: A.File.With.Dots.Instead.Of.Spaces.Extension Which I want to transform via a regex into: A File With Dots Instead Of Spaces.Extension It has to be in one regex (because I want to use it with Total Commander's batch rename tool). Help me, regex gurus, you're my only hope. Edit Several ...
I have a textarea. I am trying to check that it contains atleast 3 non-whitespace characters in javascript, and if it does, I need to recheck the posted message in php. I think once I get it working in php, I can use the same regexp for javascript. However, the whitespaces are messing it up. I don't understand why the following does no...
Not sure if I'm doing this right: /(https?:\/\/\S+)(\s|(& nbsp;))?/g; This should match a URL beginning with http(s):// and ending with a space character or a & nbsp; So the problem is this part: (\s|(& nbsp;))? That should mean: match either a white space or a & nbsp; but it doesn't work. It never matches for a & nbsp; and just c...
Hello guys, I have a problem, i can't figure out a way to get out text between symbols. site.com/hello-world/my-page-title/ i want to get my-page-title only? How? Thanks for your help, ...
Is there a utility that will convert POSIX to PCRE for PHP? I'm somewhat confused by the PHP manual on PCRE, and while I'll try to find more info on PCRE, I was wondering if anyone had designed such a utility. Or, if anyone would explain how to convert the following, that would also be fine: ereg("^#[01-9A-F]{6}$", $sColor) But pleas...
I'm writing a jFlex lexer for Lua, and I'm having problems designing a regular expression to match one particular part of the language specification: Literal strings can also be defined using a long format enclosed by long brackets. We define an opening long bracket of level n as an opening square bracket followed by n equal signs fo...
In PHP $regex = '/ ([$]) *(\d+(:?.\d+)?)/'; preg_match($regex, $str, $matches); print_r($matches[2]); This regex gives me the first occurence of a number that follows the first $ sign in a web page. Now I want a regex that would give me the number after the second $ sign and maybe the third too. ...
Question: Is is possible, with regex, to match a word that contains the same character in different positions? Condition: All words have the same length, you know the character positions (example the 1st, the 2nd and the 4th) of the repeated char, but you don't know what is it. Examples: using lowercase 6char words I'd like to match w...