Search Results

Search found 3825 results on 153 pages for 'regex negation'.

Page 26/153 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • Perl Regex Mismatch Issue

    - by Russell C.
    This is a really basic regex question but since I can't seem to figure out why the match is failing in certain circumstances I figured I'd post it to see if anyone else can point out what I'm missing. I'm trying to pull out the 2 sets of digits from strings of the form: 12309123098_102938120938120938 1321312_103810312032123 123123123_10983094854905490 38293827_1293120938129308 I'm using the following code to process each string: if($string && $string =~ /^(\d)+_(\d)+$/) { if(IsInteger($1) && IsInteger($2)) { print "success ('$1','$2')"; } else { print "fail"; } } Where the IsInterger() function is as follows: sub IsInteger { my $integer = shift; if($integer && $integer =~ /^\d+$/) { return 1; } return; } This function seems to work most of the time but fails on the following for some reason: 1287123437_1268098784380 1287123437_1267589971660 Any ideas on why these fail while others succeed? Thanks in advance for your help!

    Read the article

  • RegEx replace query to pick out wiki syntax

    - by Jeremy Thake
    I've got a string of HTML that I need to grab the "[Title|http://www.test.com]" pattern out of e.g. "dafasdfasdf, adfasd. [Test|http://www.test.com/] adf ddasfasdf [SDAF|http://www.madee.com/] assg ad" I need to replace "[Title|http://www.test.com]" this with "Title". What is the best away to approach this? I was getting close with: string test = "dafasdfasdf adfasd [Test|http://www.test.com/] adf ddasfasdf [SDAF|http://www.madee.com/] assg ad "; string p18 = @"(\[.*?|.*?\])"; MatchCollection mc18 = Regex.Matches(test, p18, RegexOptions.Singleline | RegexOptions.IgnoreCase); foreach (Match m in mc18) { string value = m.Groups[1].Value; string fulltag = value.Substring(value.IndexOf("["), value.Length - value.IndexOf("[")); Console.WriteLine("text=" + fulltag); } There must be a cleaner way of getting the two values out e.g. the "Title" bit and the url itself. Any suggestions?

    Read the article

  • How can I make this REGEX cleaner?

    - by Solignis
    I have this regex I made to compare OS names to a line in a VMX file. It started out as seperate elsif statments but I ended up making into a single if statment. Anyhow here is the code, I am trying to find a way to make the code cleaner but it put each match on a seperate line it no longer works. elsif ($vmx_file =~ m/guestOSAltName\s+=\s"Microsoft\sWindows\sServer\s2003,Web\sEdition"|"Microsoft\sWindows\sSmall\sBusiness\sServer\s2003"|"Microsoft\sWindows\s2000\sAdvanced\sServer"|"Microsoft\sWindows\s2000\sServer"|"Microsoft\sWindows\s2000\sProfessional"|"Microsoft\sWindows\s98"|"Microsoft\sWindows\s95"|"Microsoft\sWindows\sNT\s4"/) { $virtual_machines{$vm}{"Architecture"} = "32-bit";

    Read the article

  • RegEx expression to find a href links and add NoFollow to them

    - by Rodney
    I am trying to write a RegEx rule to find all a href HTML links on my webpage and add a 'rel="nofollow"' to them. However, I have a list of URLs that must be excluded (for exmaple, ANY (wildcards) internal link (eg. pokerdiy.com) - so that any internal link that has my domain name in is excluded from this. I want to be able to specify exact URLs in the exclude list too - for example - http://www.example.com/link.aspx) Here is what I have so far which is not working: (]+)(href="http://.*?(?!(pokerdiy))[^]+) If you need more background/info you can see the full thread and requirements here (skip the top part to get to the meat): http://www.snapsis.com/Support/tabid/601/aff/9/aft/13117/afv/topic/afpgj/1/Default.aspx#14737

    Read the article

  • Search pattern in string using regex in obj-c

    - by manileo86
    I'm working on a string pattern match algorithm. I use NSRegularExpression for finding the matches. For ex: I've to find all words starting with '#' in a string.. Currently I use the following regex function: static NSRegularExpression *_searchTagRegularExpression; static inline NSRegularExpression * SearchTagRegularExpression() { if (!_searchTagRegularExpression) { _searchTagRegularExpression = [[NSRegularExpression alloc] initWithPattern:@"(?<!\\w)#([\\w\\._-]+)? options:NSRegularExpressionCaseInsensitive error:nil]; } return _searchTagRegularExpression; } and I use it as below: NSRegularExpression *regexp = SearchTagRegularExpression(); [regexp enumerateMatchesInString:searchString options:0 range:stringRange usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) { // comes here for every match with range }]; This works properly. But i just want to know if this is the best way. suggest if there's any better alternative...

    Read the article

  • Getting specific values with regex

    - by David
    I need to knowingly isolate each row of the vCard and get its value. For instance, I want to get "5555" from X-CUSTOMFIELD. So far, my thoughts are: "X-CUSTOMFIELD;\d+" I have been looking at some tutorials and I am a little confused with what function to use? What would my regex above return? Would it give me the whole line or just the numerical part (5555)? I was thinking I i get the whole row, I can use substring to get the digits? BEGIN:VCARD VERSION:2.1 N:Last;First; FN:First Last TEL;HOME;VOICE:111111 TEL;MOBILE;VOICE:222222 X-CUSTOMFIELD;5555 END:VCARD

    Read the article

  • Regex pattern help (I almost have it, just need a bit of expertise to finish it)

    - by Mohammad
    I need to match two cases js/example_directory/example_name.js and js/example_directory/example_name.js?12345 (where 12345 is a digit string of unknown length and the directory can be limitless in depth or not exist at all) I need to capture in both cases everything between js/ and .js and if ? exists capture the digit string after ? This is what I have so far ^js/(.*).js\??(\d+)? This works except it also captures js/example_directory/example_name.js12345 I want the regex to ignore that. Any suggestions? Thank you all! Test your patterns here

    Read the article

  • Performing regex on a stream

    - by takoi
    I have some large text files which im going to preform consecutive matching on (just capturing, not replacing). Im thinking its not such a good idea to keep the whole file in memory, but rather use a Reader. What i know about the input is that if there's a match, its not going to span more than 5 lines. So my idea was to have some sort of buffer which just keeps these 5 lines, or so, do the first search, and continue. But it has to "know" where the regex match ended for this to work. e.g if the match ends at line 2 it should start the next search from here. Is it possible to do something like this in an efficient way?

    Read the article

  • Test/expand my email regex

    - by Ross
    I'm really not confident with Regex, I know some basic syntax but not enough to keep me happy. I'm trying to build a regular expression to check if an email is valid. So far here's what I've got: [A-Za-z0-9._-]+@[A-Za-z0-9]+.[A-Za-z.]+ It needs to take account of periods in the username/domain and I think it works with multiple TLDs (e.g. co.uk). I'm working with the preg engine in PHP so it needs to work with that. Thanks if you can help!

    Read the article

  • Converting a stopwatch time to milliseconds (regex)

    - by Nick
    I'm trying to figure out the best way to convert a string containing a time to an integer number of milliseconds. I'm using a suboptimal way using a bunch of preg_match()'s and some array handling, but I was wondering if there was an elegant way. Here are some example stopwatch times (some wouldn't actually be seen on a stopwatch but need to be converted anyway): 3:34:05.81 34:05 5 (just 5 seconds) 89 (89 seconds) 76:05 (76 minutes, 5 seconds) Millseconds will not extend past 2 decimal places. You can give me an example using either PHP or Javascript regex functions. Thanks!

    Read the article

  • Excluding a specific substring from a regex

    - by Matt S
    I'm attempting to mangle a SQL query via regex. My goal is essentially grab what is between FROM and ORDER BY, if ORDER BY exists. So, for example for the query: SELECT * FROM TableA WHERE ColumnA=42 ORDER BY ColumnB it should capture TableA WHERE ColumnA=42, and it should also capture if the ORDER BY expression isn't there. The closest I've been able to come is SELECT (.*) FROM (.*)(?=(ORDER BY)) which fails without the ORDER BY. Hopefully I'm missing something obvious. I've been hammering in Expresso for the past hour trying to get this.

    Read the article

  • Bash script with regex not behaving on Ubuntu

    - by user265330
    I have a Bash script that is working on my OpenSuSE box, but when copied across to my Ubuntu box, is not working. The script reads in from a file. The file has fields separated by white space (tabs and spaces). #!/bin/bash function test1() { while read LINE do if [[ $LINE =~ "^$" || $LINE =~ "^#.*" ]] ; then continue; fi set -- $LINE local field1=$1 local field2=$2 done < test.file } test1 with test.file containing: # Field1Header Field2Header abcdef A-2 ghijkl B-3 There seem to be two problems: (1) $field2, the one with the hyphen, is blank (2) The regex to strip out the blank lines and lines that start with # is not working Anyone know what's wrong? As I said, it works fine on OpenSuSE. Thanks, Paul

    Read the article

  • Regex to *not* match any characters

    - by Erick
    I know it is quite some weird goal here but for a quick and dirty fix for one of our system we do need to not filter any input and let the corruption go into the system. My current regex for this is "\^.*" The problem with that is that it does not match characters as planned ... but for one match it does work. The string that make it not work is ^@jj (basically anything that has ^ ... ). What would be the best way to not match any characters now ? I was thinking of removing the \  but only doing this will transform the "not" into a "start with" ...

    Read the article

  • Regex to replace a string in HTML but not within a link or heading

    - by Vladimir
    I am looking for a regex to replace a given string in a html page but only if the string is not a part of the tag itself or appearing as text inside a link or a heading. Examples: Looking for 'replace_me' <p>You can replace_me just fine</p> OK <a href='replace_me'>replace_me</a> no match <h3>replace_me</h3> no match <a href='/test/'><span>replace_me</span></a> no match <p style="background:url('replace_me')">replace_me<h1>replace_me</h1></p> first no match, second OK, third no match Thanks in advance!

    Read the article

  • Javascript Regex: how to remove string before > and including >

    - by Kim Jong Woo
    I have a string like so item[3]>something>another>more[1]>here hey>this>is>something>new . . . I would like to produce the following for each iteration indicated by each new line item[3]>something>another>more[1]>here something>another>more[1]>here another>more[1]>here more[1]>here here Another example: hey>this>is>something>new this>is>something>new is>something>new something>new new I would like a regex or some way to incrementally remove the furthest left string up to .

    Read the article

  • Javascript string.replace with regex

    - by Jimbo
    I want to replace a url querystring parameter with a new value if it already exists or add it on if not. e.g. The current url could be: a. www.mysite.com/whatever.asp?page=5&version=1 OR b. www.mysite.com/whatever.asp?version=1 I need the resulting url to be www.mysite.com/whatever.asp?page=1&version=1 I suspect I can use string.replace with a regex to do this the most intelligent way but am hoping for a little help with it from someone more experienced with regexs :) Thanks!

    Read the article

  • Python: Regex outputs 12_34 - I need 1234

    - by Guy F-W
    So I have input coming in like: 12_34 5_6_8_2 4___3 1234 and the output I need from it is: 1234, 5682, 43, 1234 I'm currently working with r'[0-9]+[0-9_]*'.replace('_','') which (as far as I can tell) successfully rejects any input which is not a combination of numeric digits and under-scores, where the underscore cannot be the first character. However, replacing the _ with the empty string causes 12_34 to come out as 12 and 34. Is there a better method than 'replace' for this? Or could I adapt my regex to deal with this problem?

    Read the article

  • RewriteRule not working do not know how to test it the regex matches

    - by user564559
    Hello I have a Rewrite rule I am trying to implement on my local host but I cannot get it to do the action no matter how I setup the regex the files are in this naming scheme /docroot/css/stylesheet.min.css and I have them printed in the code like /docroot/css/stylesheet.min.123438348.css (the number is example it comes from a get modified function). Note docroot is an example directory how can I have the server ignore the numbers and redirect to the stylesheet.min.css I need to do this for every css and js files (/js and /css) as well as one specific spritemap image my current attempt RewriteRule ^/(docroot)/(js|css)/(.+)\.(min)\.(.+)\.(js|css)$ /$1/$2/$3.$4.$6 RewriteRule ^(/docroot/images/spritemap)\.([0-9]+)\.(png)$ $1.$3 I have this wrapped in a I am on linux..should this be mod_rewrite.so?"

    Read the article

  • How to test a regex password in Python?

    - by jCuga
    Using a regex in Python, how can I verify that a user's password is: At least 8 characters Must be restricted to, though does not specifically require any of: uppercase letters: A-Z lowercase letters: a-z numbers: 0-9 any of the special characters: @#$%^&+= Note, all the letter/number/special chars are optional. I only want to verify that the password is at least 8 chars in length and is restricted to a letter/number/special char. It's up to the user to pick a stronger / weaker password if they so choose. So far what I have is: import re pattern = "^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$" password = raw_input("Enter string to test: ") result = re.findall(pattern, password) if (result): print "Valid password" else: print "Password not valid"

    Read the article

  • C# Regex: only letters followed by an optional .

    - by TheDude
    Hello, I am looking for a way to get words out of a sentence. I am pretty far with the following expression: \b([a-zA-Z]+?)\b but there are some occurrences that it counts a word when I want it not to. E.g a word followed by more than one period like "text..". So, in my regex I want to have the period to be at the end of a word zero or one time. Inserting .? did not do the trick, and variations on this have not yielded anything fruitful either. Hope someone can help!

    Read the article

  • Return result of block passed to #scan during regex

    - by Oli
    I've searched and not been able to find the right way of doing what I'm trying to. I read a file line by line and want to create a new object from a regex on each line. I'm not using an XML parser because the data is not well formed and listed below is all I need to get from each line. I can't seem to get scan to return the result of the block. It just returns the original string. I have temporarily gotten around it by creating this temp variable, but I'm sure there is a better way. enum = File.foreach(filename) enum.map do |line| temp = nil line.scan(/<cab id="(\w+)" updates="(\d+)"/) { |a,b| temp = Cab.new(a,b) } temp end Thanks for any help.

    Read the article

  • Get n Number of words using regex in Java

    - by Aymon Fournier
    I have a section of a book, complete with punctuation, line breaks etc. and I want to be able to extract the first n words from the text, and divide that into 5 parts. Regex mystifies me. This is what I am trying. I creates an array of index size 0, with all the input text: public static String getNumberWords2(String s, int nWords){ String[] m = s.split("([a-zA-Z_0-9]+\b.*?)", (nWords / 5)); return "Part One: \n" + m[1] + "\n\n" + "Part Two: \n" + m[2] + "\n\n" + "Part Three: \n" + m[3] + "\n\n" + "Part Four: \n" + m[4] + "\n\n" + "Part Five: \n" + m[5]; } Thanks!

    Read the article

  • RegEx - character not before match

    - by danneth
    I understand the consepts of RegEx, but this is more or less the first time I've actually been trying to write some myself. As a part of a project, I'm attempting to parse out strings which match to a certain domain (actually an array of domains, but let's keep it simple). At first I started out with this: url.match('www.example.com') But I noticed I was also getting input like this: http://www.someothersite.com/page?ref=http://www.example.com These rows will ofcourse match for www.example.com but I wish to exclude them. So I was thinking along these lines: Only match rows that contain www.example.com, but not after a ? character. This is what I came up with: var reg = new RegExp("[^\\?]*" + url + "(\\.*)", "gi"); This does however not seem to work, any suggestions would be greatly appreciated as I fear I've used what little knowledge I yet possess in the matter.

    Read the article

  • How do I insert format str and don't remove the matched regular expression in input string in boost:

    - by Yadollah
    I want to put space between punctuations and other words in a sentence. But boost::regex_replace() replaces the punctuation with space, and I want to keep a punctuation in the sentence! for example in this code the output should be "Hello . hi , " regex e1("[.,]"); std::basic_string<char> str = "Hello.hi,"; std::basic_string<char> fmt = " "; cout<<regex_replace(str, e1, fmt)<<endl; Can you help me?

    Read the article

  • Text replace with regex in SQL Server

    - by Thiyaneshwaran S
    Currently I have a SQL server column of type nvarchar(max) which has text that starts with <span class="escape_<<digits>>"></span> The only thing that varies in the pattern is the <<digits>> in the class name. The common part is <span class="myclass_ and the closing </span> Some sample values are <span class="myclass_12"></span> <span class="myclass_234"></span> <span class="myclass_4546"></span> These span text are present only at the beginning of the column. Any such matching span in the middle should not be removed or matched. Whats the SQL Server query with regex to remove all these occurances of span?

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >