regex

preg_match & regex fail to catch full url with filename "a.jpg_x.jpg"

Hi, I use in my code : preg_match( '!http://[^?#]+\.(?:jpe?g|png|gif)!Ui' , $str[1], $results ); It work in most cases except: src='http://www.domain.com/Pic/folder1/folder2/a.jpg_x.jpg' alt= I get: ......older2/a.jpg I need: .....older2/a.jpg_x.jpg any ideas? Thanks in advance ...

regex pattern to match only strings that don't contain spaces PHP

Hi, I want to match the word/pattern that is contained in the variable, but only match against the words that don't have white spaces. Please give suggestions. $var = 'look'; $array = ('look', 'greatlook', 'lookgreat', 'look great', 'badlook', 'look bad', 'look ', ' look'); matches words: look, greatlook, lookgrea...

Regular Expression; Find whether a line contains any word with more than X characters.

Hi, I am trying to use a Validator on a ASP.NET site and need to find whether the Street Address textbox contains a valid entry. Entries with words that are longer than X characters (in this case 25, with no punctuation or spaces) will cause the HTML on a printed A4 page to not wrap properly and therefore not to confrom to certain size...

Regex to match a string that does not contain any words longer than 10 characters?

^(.)+\S{10}(.)+$ I have that regex which will match any string that contains a word of 10 characters. However I need the INVERSE of that. A regex that will only match strings which do NOT have words of >=10 characters. ...

Is it possible to join these two regex expressions into one?

Hi folks, i have the following two regular expressions (in order btw). 1. ^~/buying/(.*)\?(.*) => foo= group 1 baa= group 2. 2. ^~/buying/(.*) => foo= group 1 baa= nothing/empty/null/baibai What's i'm trying to do is, if the url has a questionmark, then split it into two groups. Otherwise, just throw all the stuff into th...

sorting in python

I have a hashmap like so: results[tweet_id] = {"score" : float(dot(query,doc) / (norm(query) * norm(doc))), "tweet" : tweet} What I'd like to do is to sort results by the innser "score" key. I don't know how possible this is, I saw many sorting tutorials but they were for simple (not nested) data structures. ...

MySQL cross table regular expression match

I have a web application and I am working on engine that analyzes referals. Now I have table with pageviews along with referes that looks something like this: pv_id referer ------------------------------------------------------------ 5531854534 http://www.google.com/search?ie=UTF-8... 8161876343 http://google.cn/search?searc...

Parsing XML file with perl - regex

Hi Everyone, i'm just a begginer in perl, and very urgently need to prepare a small script that takes top 3 things from an xml file and puts them in a new one. Here's an example of an xml file: <article> {lot of other stuff here} </article> <article> {lot of other stuff here} </article> <article> {lot of other stuff here} </ar...

Regex not equal to string

Hi, I'm banging my head against a wall with a regular expression. I'm trying to define an expression that excludes exactly this text 'System' (case insensitive), but can contain the word 'System' providing it's not just that. Examples: System == INVALID SYSTEM == INVALID system == INVALID syStEm == INVALID asd SysTem == Valid asd Sys...

jQuery Youtube URL Validation with regex

I know there is plenty of question answered over here http://stackoverflow.com/questions/tagged/youtube+regex, but not able find a question similar to me. Any body has the JavaScript Regular expression for validating the YouTube VIDEO URL's line below listed. Just want to know where such a URL can be possible http://www.youtube.com/wat...

Neither-nor oneline REGEXP

Hi! Is it possible to write a regexp rule in "one line" that says: neither A nor B. For example: String must contain NEITHER "foo" NOR "bar". Why one line? Because the filtering tool I am using accepts only one line ... I have tried things like (.*foo.*){0}(.*bar.*){0} without enough luck. ...

preg_match in php

I want to use preg_match() such that there should not be special characters such as `@#$%^&/ ' in a given string. For example : Coding : Outputs valid : Outputs Invalid(String beginning with space) Project management :Outputs valid (space between two words are valid) 'Design23' :Outputs valid 23Designing : outputs invalid 123 :Outputs ...

parse string with regular exression

I trying to parse this string: $right = '34601)S(1,6)[2] - 34601)(11)[2] + 34601)(3)[2,4]'; with following regexp: const word = '(\d{3}\d{2}\)S{0,1}\([^\)]*\)S{0,1}\[[^\]]*\])'; preg_match('/'.word.'{1}(?:\s{1}([+-]{1})\s{1}'.word.'){0,}/', $right, $matches); print_r($matches); i want to return array like this: Array ( [0] => ...

Are there any way to apply regexp in java ignoring letter case?

Simple example: we have string "Some sample string Of Text". And I want to filter out all stop words (i.e. "some" and "of") but I don't want to change letter case of other words which should be retained. If letter case was unimportant I would do this: str.toLowerCase().replaceAll ("a|the|of|some|any", ""); Is there an "ignore case" ...

Optional param Zend Route Regex

Hello, How to make route regex parameters optionals with Zend ? I try to make well formatted URLs ("search?s=mp&t=w" instead of "search/index/s/mp/t/w") for search filters, ex. : Popularity Most popular (s=mp) Most viewed (s=mv, default) Top rated (s=tr) Most commented (s=mc) Period All period (t=a, default) Today...

Censoring selected words (replacing them with ****) using a single replaceAll?

I'd like to censor some words in a string by replacing each character in the word with a "*". Basically I would want to do String s = "lorem ipsum dolor sit"; s = s.replaceAll("ipsum|sit", $0.length() number of *)); so that the resulting s equals "lorem ***** dolor ***". I know how to do this with repeated replaceAll invokations, but...

Javascript RegExp and boundaries

Hi Guys, A colleague asked me about a Regular expression problem, and I can't seem to find and answer for him. We're using boundaries to highlight certain lengths of text in a text editor, but here's some sample code that shows the problem: <script type="text/javascript"> var str = "Alpha , Beta, Gamma Delta Epsilon, AAlphaa, Beta Alp...

How to replace a regexp group with a post proceed value?

I have this code to public static String ProcessTemplateInput(String input, int count) { Pattern pattern = Pattern.compile("\\{([^\\}]+)\\}"); Matcher matcher = pattern.matcher(input); while (matcher.find()) { String newelem=SelectRandomFromTemplate(matcher.group(1), count); } return ...

Lookahead regex produces unexpected group

I'm trying to extract a page name and query string from a URL which should not contain .html Here is an example code in Java: public class TestRegex { public static void main(String[] args) { Pattern pattern = Pattern.compile("/test/(((?!\\.html).)+)\\?(.+)"); Matcher matcher = pattern.matcher("/test/page?param=val...

Intersection of two regular expressions

Hi, Im looking for function (PHP will be the best), which returns true whether exists string matches both regexpA and regexpB. Example 1: $regexpA = '[0-9]+'; $regexpB = '[0-9]{2,3}'; hasRegularsIntersection($regexpA,$regexpB) returns TRUE because '12' matches both regexps Example 2: $regexpA = '[0-9]+'; $regexpB = '[a-z]+'; has...