Search Results

Search found 3804 results on 153 pages for 'regex'.

Page 32/153 | < Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >

  • How to get rid of duplicates in regex

    - by Emmanuel Smith
    Suppose I had a string, "cats cats cats and dogs dogs dogs." What regular expression would I use in order to replace that string with,"cats and dogs." i.e. removing duplicates. The expression however must only remove duplicates that follow after each other. For instance: "cats cats cats and dogs dogs dogs and cats cats and dogs dogs" Would return: "cats and dogs and cats and dogs"

    Read the article

  • JS regex and angle brackets

    - by chaz
    Seriously, why can't I parse a string with angle brackets using the Javascript regular expression object? var r = new RegExp(), r; r.compile("\\<div\\>", "g"); r = r.exec("<div>Hello</div>"); //Equals null yo Why does that not work?

    Read the article

  • get particular string using regex java

    - by hussain
    i want to know how to get the string from group of string String j = "<a href=\"/watch?v=4Qx-lBqOqiQ&feature=popular\" onclick=\"\" onmousedown=\"yt.analytics.urchinTracker(\'/Events/Home/PersonalizedHome/POP/Logged_Out');\" ><span class=\"video-thumb video-thumb-220 \" id=\"video-thumb-4Qx-lBqOqiQ-8821469\"><img src=\"http://i1.ytimg.com/vi/4Qx-lBqOqiQ/hqdefault.jpg\" class=\"vimg220\" alt=\"Dog Squirrel Chasing A Squirrel\" title=\"Dog Squirrel Chasing A Squirrel\" onclick=\";yt.www.watch.watch5.IEshenanigans(event, this)\"><span class=\"video-time\"><span>1:08</span></span><span class=\"video-actions\"><button class=\"yt-uix-button-short yt-uix-button yt-uix-button-arrowbutton\" onclick=\"; return false;\" type=\"button\"> <img class=\"yt-uix-button-arrow\" src=\"http://s.ytimg.com/yt/img/pixel-vfl73.gif\" alt=\"\"> hai</a>"; i want to get the string href=\"/watch?v=4Qx-lBqOqiQ&feature=popular\" and src=\"http://i1.ytimg.com/vi/4Qx-lBqOqiQ/hqdefault.jpg\" thanks and advance

    Read the article

  • Regex: Strip HTML attributes except SRC

    - by Ian Silber
    Hi, I'm trying to write a regular expression that will strip all tag attributes except for the SRC attribute. For example: <p id="paragraph" class="green">This is a paragraph with an image <img src="/path/to/image.jpg" width="50" height="75"/></p> Would be returned as: <p>This is a paragraph with an image <img src="/path/to/image.jpg" /></p> I have a regular expression to strip all attributes, but I'm trying to tweak it to leave in src. Here's what I have so far: <?php preg_replace('/<([A-Z][A-Z0-9]*)(\b[^>]*)>/i', '<$1>', '<html><goes><here>'); Using PHP's preg_replace() for this. Thanks! Ian

    Read the article

  • JavaScript regex refactoring

    - by JamesBrownIsDead
    I'm performing this on a string: var poo = poo .replace(/[%][<]/g, "'<") .replace(/[>][%]/g, ">'") .replace(/[%]\s*[+]/g, "'+") .replace(/[+]\s*[%]/g, "+'"); Given the similar if these statements, can these regexs be comebined somehow?

    Read the article

  • Regex matching wrong strings

    - by Joe Smalley
    I have this PHP/SQL query: $sql = sprintf("SELECT * FROM %sCubeCart_filemanager WHERE filepath REGEXP '%s[\\/\\\\][^\\/\\\\]+$' AND type = '%d' AND disabled = '0' ORDER BY filepath ASC %s", $this->_config['dbprefix'], str_replace(array('\\','/'),'.',$folder), $type, $limit); if '$folder' == 'iha9' it is finding results like 'iha91' and 'iha99' too. Something is wrong with the regular expression, but I don't know how they work, can anyone help?!

    Read the article

  • regex in textfield

    - by klox
    dear all..i have this code: <script> var str="KD-R435MUN2D"; var matches=str.match(/(EE|[EJU]).*(D)/i); if (matches) { var firstletter = matches [1]; var secondletter = matches [2]; var thirdletter = matches [3]; alert(firstletter + secondletter + thirdletter); }else{ alert (":("); } </script> i want it can control a textfield <input type="text" id="mod">..how must i do?

    Read the article

  • Search for content in functions with regex

    - by Marlun
    Hello, How would I with regular expression search for functions which contains the use of a global variable without running "global $var" first? The files looks like this: class TestClass { function correctFunc() { global $var; $name = $var->name; } function invalidFuncIWantToFind() { $age = $var->user->age; } } I want to find the function names of all the invalidFuncIWantToFind. At work this would have really speeded up our work but I didn't get how to do it.

    Read the article

  • Scala capture group using regex

    - by Geo
    Let's say I have this code: val string = "one493two483three" val pattern = """two(\d+)three""".r pattern.findAllIn(string).foreach(println) I expected findAllIn to only return 483, but instead, it returned two483three. I know I could use unapply to extract only that part, but I'd have to have a pattern for the entire string, something like: val pattern = """one.*two(\d+)three""".r val pattern(aMatch) = string println(aMatch) // prints 483 Is there another way of achieving this, without using the classes from java.util directly, and without using unapply?

    Read the article

  • UNIX-style RegExp Replace running extremely slowly under windows. Help? EDIT: Negative lookahead ass

    - by John Sullivan
    I'm trying to run a unix regEXP on every log file in a 1.12 GB directory, then replace the matched pattern with ''. Test run on a 4 meg file is took about 10 minutes, but worked. Obviously something is murdering performance by several orders of magnitude. Find: ^(?!.*155[0-2][0-9]{4}\s.*).*$ -- NOTE: match any line NOT starting 155[0-2]NNNN where in is a number 0-9. Replace with: ''. Is there some justifiable reason for my regExp to take this long to replace matching text, or is the program I am using (this is windows / a program called "grepWin") most likely poorly optimized? Thanks. UPDATE: I am noticing that searching for ^(155[0-2]).$ takes ~7 seconds in a 5.6 MB file with 77 matches. Adding the Negative Lookahead Assertion, ?=, so that the regExp becomes ^(?!155[0-2]).$ is causing it to take at least 5-10 minutes; granted, there will be thousands and thousands of matches. Should the negative lookahead assertion be extremely detrimental to performance, and/or a large quantity of matches?

    Read the article

  • Finding words strictly starting with $, Regex C#

    - by Anirudh Goel
    I need to find all matches of word which strictly begins with "$" and contains only digits. So I wrote [$]\d+ which gave me 4 matches for $10 $10 $20a a$20 so I thought of using word boundaries using \b: [$]\d+\b But it again matched a$20 for me. I tried \b[$]\d+\b but I failed. I'm looking for saying, ACCEPT ONLY IF THE WORD STARTS WITH $ and is followed by DIGITS. How do I tell IT STARTS WITH $, because I think \b is making it assume word boundaries which means surrounded inside alphanumeric characters. What is the solution?

    Read the article

  • Regex Help matching quotes

    - by Farhan
    Hi Guys, I havin a reg ex problemm i would like to have a reg ex that will match the '\nGO at the end of my file(see below.) I have got the following so far: ^\'*GO but its match the quote sysbol? EOF: WHERE (dbo.Property.Archived <> 1) ' GO

    Read the article

  • regex to format a float in php

    - by Itamar Bar-Lev
    I have a PHP function for formatting a float to a given amount of decimal points that uses number_format(), and then removes the unneeded zeros (and also the '.' if possible): $float = number_format($float, $decimalPlaces, '.', ''); for ($i = 0; $i < $decimalPlaces; $i++) { if (substr($float, strlen($float) - 1, strlen($float)) == '0') { $float = substr($float, 0, strlen($float) - 1); } } if (substr($float, strlen($float) - 1, strlen($float)) == '.') { $float = substr($float, 0, strlen($float) - 1); } Is it possible to do so more effectively with a regular expression?

    Read the article

  • Using Regex groups in bash

    - by AlexeyMK
    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 worked this way' is convert *.pdf *.png But clearly that doesn't work. My thought process is that I should utilize regular expression grouping here, to say somethink like convert (*).pdf %1.png but that clearly isn't the right syntax. I'm wondering what the correct syntax is, and whether there's a better approach (that doesn't require jumping into perl or python) that I'm ignoring. Thanks!

    Read the article

  • VBA regex pattern

    - by KeyMs92
    This is probably a simple problem, but unfortunately I wasn't able to get the results I wanted... Say, I have the following line: "Wouldn't It Be Nice" (B. Wilson/Asher/Love) I would have to look for this pattern: " (<any string>) In order to retrieve: B. Wilson/Asher/Love I tried something like "" (([^))]*)) but it doesn't seem to work. Also, I'd like to use Match.Submatches(0) so that might complicate things a bit because it relies on brackets...

    Read the article

  • php preg_match pattern to extract a specific information, regex

    - by Michael
    I need to extract a specific Id from a html document but the problem is that the id must not "be used". Here is the html content http://pastebin.com/wF2dx8JZ As you may see there are different html blocks . Some of them contain the "Used" word so I need to extract only the first id which is not used. Basically I can write a simple pattern like : $pattern = "/javascript:tw(.*))/"; preg_match_all($pattern, $content, $matches); $id = $matches[1][0]; However in this case I'm also getting the "ids" which are used so I don't know how to exclude them from the equation . Any idea would be highly appreciated.

    Read the article

  • python regex of a date in some text, enclosed by two keywords

    - by Horace Ho
    This is Part 2 of this question and thanks very much for David's answer. What if I need to extract dates which are bounded by two keywords? Example: text = "One 09 Jun 2011 Two 10 Dec 2012 Three 15 Jan 2015 End" Case 1 bounding keyboards: "One" and "Three" Result expected: ['09 Jun 2011', '10 Dec 2012'] Case 2 bounding keyboards: "Two" and "End" Result expected: ['10 Dec 2012', '15 Jan 2015'] Thanks!

    Read the article

  • Numbering Regex Submatches

    - by gentlylisped
    Is there a canonical ordering of submatch expressions in a regular expression? For example: What is the order of the submatches in "(([0-9]{3}).([0-9]{3}).([0-9]{3}).([0-9]{3}))\s+([A-Z]+)" ? a. (([0-9]{3})\.([0-9]{3})\.([0-9]{3})\.([0-9]{3}))\s+([A-Z]+) (([0-9]{3})\.([0-9]{3})\.([0-9]{3})\.([0-9]{3})) ([A-Z]+) ([0-9]{3}) ([0-9]{3}) ([0-9]{3}) ([0-9]{3}) b. (([0-9]{3})\.([0-9]{3})\.([0-9]{3})\.([0-9]{3}))\s+([A-Z]+) (([0-9]{3})\.([0-9]{3})\.([0-9]{3})\.([0-9]{3})) ([0-9]{3}) ([0-9]{3}) ([0-9]{3}) ([0-9]{3}) ([A-Z]+) or c. somthin' else.

    Read the article

  • What does this regex do?

    - by Lizard
    ^.+\\(.*\\) I am struggling to work this one out, any help would be greatly appreciated... also is there a site that lets youu paste in a regular expression then spits out in plain text what it means?

    Read the article

  • How to find files according RegEx in C#

    - by bao
    I need to get list of files on some drive with paths that matches specific pattern, for example FA\d\d\d\d.xml where \d is digit (0,1,2..9). So files can have names like FA5423.xml. What is the most efficient name to do this?

    Read the article

< Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >