Search Results

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

Page 14/153 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Why does my Perl regex complain about "Unmatched ) in regex"?

    - by NJTechGuy
    if($title =~ s/(\s|^|,|\/|;|\|)$replace(\s|$|,|\/|;|\|)//ig) $title can be a set of titles ranging from President, MD, COO, CEO,... $replace can be (shareholder), (Owner) or the like. I keep getting this error. I have checked for improperly balanced '(', ')', no dice :( Unmatched ) in regex; marked by <-- HERE in m/(\s|^|,|/|;|\|)Owner) <-- HERE (\s|$|,|/|;|\|)/ If you could tell me what the regex does, that would be awesome. Does it strip those symbols? Thanks guys!

    Read the article

  • A PHP regex to extract php functions from code files

    - by user298593
    I'm trying to make a PHP regex to extract functions from php source code. Until now i used a recursive regex to extract everything between {} but then it also matches stuff like if statements. When i use something like: preg_match_all("/(function .(.))({([^{}]+|(?R))*})/",$this-data,$matches2); It doesn't work when there is more than 1 function in the file (probably because it uses the 'function' part in the recursiveness too). Is there any way to do this? Example file: <?php if($useless) { echo "i don't want this"; } function bla($wut) { echo "i do want this"; } ?> Thanks

    Read the article

  • Regex to validate initials

    - by iar
    I'm looking for a regex to validate initials. The only format I want it to allow is: (a capital followed by a period), and that one or more times Valid examples: A. A.B. A.B.C. Invalid examples: a. a A A B A B C AB ABC Using The Regulator and some websites I have found the following regex, but it only allows exactly one upper (or lower!) case character followed by a period: ^[A-Z][/.]$ Basically I only need to know how to force upper case characters, and how I can repeat the validation to allow more the one occurence of an upper case character followed by a period.

    Read the article

  • Need help with this Regex + UrlRewriter.NET please :)

    - by Pure.Krome
    Previously, on StackOverflow ... (Summarized) I need to capture all requests, for a particluar subdomain .. and rewrite their destination. Now, the trick to determining the host via regex was solved. Now, i need to make sure all requests to the root index page is rewritten, but i can't figure out the correct regex to find the 'homepage' / website root. this is what i have.... <if header="HTTP_HOST" match="^foo\.mydomain\.com\.au(?::\d+)?/?$"> <!-- snip some other rewrites, eg./buying/product -> ~/Pages/Foo/Bar.aspx --> <rewrite url="^/$" to="~/Pages/SomeWeirdFolder/Home.aspx" processing="stop"/> </if> Now if one of the rewrites were not found, then it falls through and continues. So .. can anyone please help?

    Read the article

  • Regex: absolute url to relative url (C#)

    - by splatto
    I need a regex to run against strings like the one below that will convert absolute paths to relative paths under certain conditions. <p>This website is <strong>really great</strong> and people love it <img alt="" src="http://localhost:1379/Content/js/fckeditor/editor/images/smiley/msn/teeth_smile.gif" /></p> Rules: - If the url contains "/Content/" I would like to get the relative path - If the url does not contain "/Content/", it is an external file, and the absolute path should remain Regex unfortunatley is not my forte, and this is too advanced for me at this point. If anyone can offer some tips I'd appreciate it. Thanks in advance.

    Read the article

  • Multiple delimiters using Regex.Split in C#

    - by Arthur Frankel
    Let's say you need to split a string by various delimiters including newline (/r, /n) and a few other 'special' character strings. For example: This is a sample %%% text &&& that I would like to split %%% into an array. I would like the following in the resulting string array (contents via index) [0]This is a sample [1]text [2]that I would [3]like to split [4]into an array. I would like to use C# Regex.Split() function. What is the regex expression to match on all of my delimiters? Thanks in advance

    Read the article

  • RegEx to match a pattern and exclude a part of the string

    - by rojanu
    Hi, I have got some strings to be matched via RegEx. We have a java application which reads the regex from a config file and takes two groups of strings, number of which are specified in the same config. E.g. CustomAction.523274ca945f.dialogLabel=Executing Custom Code... will be matched with (?m)^(?!#)\s*(\S*)\s*=\s*(\S*.*) What I need is to pick the first group "CustomAction.523274ca945f.dialogLabel" and exclude the random string in the middle so I end up with something like "CustomAction.dialogLabel" or "CustomAction..dialogLabel" well any other combination but the random string. Thanks

    Read the article

  • How do I format this regex so it will work in fail2ban?

    - by chapkom
    I've just installed fail2ban on my CentOS server in response to an SSH brute force attempt. The default regular expressions in fail2ban's sshd.conf file do not match any entries in audit.log, which is where SSH seems to be logging all connection attempts, so I am trying to add an expression that will match. The string I am trying to match is as follows: type=USER_LOGIN msg=audit(1333630430.185:503332): user pid=30230 uid=0 auid=500 subj=user_u:system_r:unconfined_t:s0-s0:c0.c1023 msg='acct="root": exe="/usr /sbin/sshd" (hostname=?, addr=<HOST IP>, terminal=sshd res=failed)' The regular expression I am attempting to use is: ^.*addr=<HOST>, terminal=sshd res=failed.*$ I've used regextester.com and regexr to try to build the regex. The testers give me a match for this regex:^.*addr=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}, terminal=sshd res=failed.*$ but fail2ban-regex complains if I don't use the <HOST> tag in the regex. However, using ^.*addr=<HOST>, terminal=sshd res=failed.*$ gives me 0 matches. At this point, I am totally stuck and I would greatly appreciate any assistance. What am I doing wrong in the regex I am trying to use?

    Read the article

  • REGEX HELP: SUBDOMAIN CHECK

    - by NoviceCoding
    Hey I have a form where the person enters the subdomain like value.google.com and the entry would be "valid" I want to run a regex check (I am absolutely horrible at regex) that does the following: First Character: Cannot be symbol Middle Characters: a-z, A-Z, and symbols - and . ONLY Last character: Cannot be a symbol I want it to spit out false if it fails the test. Can anyone help me out with this? Thanks! Also any other limitations do you guys think should be in there?

    Read the article

  • Regex help -- cleaning up whitespace -- Java

    - by FarmBoy
    I'm trying to view the text of HTML files in a reasonable way. After I remove all of the markup and retain only the visible text, I obtain a String that looks something like this: \n\n\n\n \n\n\n \n\n \n Title here \n\n\n \n\n \n\n Menu Item 1 \n\n \n\n Menu Item 2 \n\n\n \n\n you get the point. I would like to use String.replaceAll(String regex, String regex) to replace any whitespace substring that contains more than two occurances of \n with "\n\n". Any ideas?

    Read the article

  • Replace text in string with delimeters using Regex

    - by user1057735
    I have a string something like, string str = "(50%silicon +20%!(20%Gold + 80%Silver)| + 30%Alumnium)"; I need a Regular Expression which would Replace the contents in between ! and | with an empty string. The result should be (50%silicon +20% + 30%Alumnium). If the string contains something like (with nested delimiters): string str = "(50%silicon +20%!(80%Gold + 80%Silver + 20%!(20%Iron + 80%Silver)|)| + 30%Alumnium)"; The result should be (50%silicon +20% + 30%Alumnium) - ignoring the nested delimiters. I've tried the following Regex, but it doesn't ignore the nesting: Regex.Replace(str , @"!.+?\|", "", RegexOptions.IgnoreCase);

    Read the article

  • RegEx/Javascript validation: Don't allow comma as a valid character

    - by baldwingrand
    I'm doing Javascript validation on my number fields. I'm using RegEx to do this - first time RegEx user. I need the user to only enter numbers and decimals, but not commas. (i.e. 3600.00 is okay, but 3,600.00 is not). I can't figure out how to eliminate the commas as an accepted character. Any help is appreciated. Thanks! var filter = /^([0-9])/; if (!filter.test(txtItemAmount.value)) { msg += "Item amount must be a number.\n"; txtItemAmount.focus }

    Read the article

  • asp.net regex to find anchor tags and replace their url

    - by ace
    Hi -i'm trying to find all the anchor tags and appending the href value with a variable. for example <a href="/page.aspx">link</a> will become <a href="/page.aspx?id=2"> <A hRef='http://www.google.com'><img src='pic.jpg'></a> will become <A hRef='http://www.google.com?id=2'><img src='pic.jpg'></a> I'm able to match all the anchor tags and href values using regex, then i manually replace the values using string.replace, however i dont think its the efficient way to do this. Is there a solution where i can use something like regex.replace(html,newurlvalue)

    Read the article

  • Gruber URL Regex tweak to capture "domain.com"

    - by mootymoots
    I found an updated version of John Gruber's regex for url matching in this post by user GianPac, which states it's been adapted to recognize url without protocol or the www part: (?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.-]+[.][a-z]{2,4}/?)(?:[^\s()<]+|(([^\s()<]+|(([^\s()<]+)))))(?:(([^\s()<]+|(([^\s()<]+))))|[^\s`!()[]{};:'\".,<?«»“”‘’])) Whilst this works in most cases, I found it does not match "google.com". It does match "google.comm" and "google.co.uk", so this must be a small oversight. The trouble is, I literally hate regex. It's the bane of my life. I just want to try and tweak this one more time to allow for "google.com" - can anyone throw me a pointer? I (think) it's something to do with this part of the code: +[.][a-z]{2,4}/?) ?

    Read the article

  • Regex to match CSV file nested quotes

    - by user361970
    Hi, I know this has been discussed a million times. I tried searching through the forums and have seen some close regex expressions and tried to modify them but to no avail. Say there is a line in a csv file like this: "123", 456, "701 "B" Street", 910 Is there an easy regex to detect "B" (since its a non-escaped set of quotes within the normal CSV quotes) and replace it with something like \"B\" ? The final string would end up looking like this: "123", 456, "701 \"B\" Street", 910 Help would be greatly appreciated!

    Read the article

  • Regex problem ...

    - by carlos
    hello i have the next regex Dim origen As String = " /c /p:""c:\mis doc umentos\mis imagenes construida\archivo.txt"" /cid:45 423 /z:65 /a:23 /m:39 /t:45rt " Dim str As String = "(^|\s)/p:""\w:(\\(\w+[\s]*\w+)+)+\\\w+.\w+""(\s|$)" Dim ar As Integer Dim getfile As New Regex(str) Dim mgetfile As MatchCollection = getfile.Matches(origen) ar = mgetfile.Count When i evaluate this it works, and gets the /p:""c:\mis doc umentos\mis imagenes construida\archivo.txt"" that basically is the path to a file. But if I change the origen string to Dim origen As String = " /c /p:""c:\mis doc umentos\mis imagenes construida\archivo.txt""/cid:45 423 /z:65 /a:23 /m:39 /t:45rt " Check that the end of the file is follow by "/cid:45" whitchs makes de patter invalid, but insted of getting a mgetfile.count = 0 the program is block, if i make a debug I got a property evaluation failed. Thanks for your comments !!!

    Read the article

  • python regex for repeating string

    - by Lars Nordin
    I am wanting to verify and then parse this string (in quotes): string = "start: c12354, c3456, 34526;" //Note that some codes begin with 'c' I would like to verify that the string starts with 'start:' and ends with ';' Afterward, I would like to have a regex parse out the strings. I tried the following python re code: regx = r"V1 OIDs: (c?[0-9]+,?)+;" reg = re.compile(regx) matched = reg.search(string) print ' matched.groups()', matched.groups() I have tried different variations but I can either get the first or the last code but not a list of all three. Or should I abandon using a regex?

    Read the article

  • Regex to String generation

    - by Mifmif
    Let's say that we have a regex and an index i , if we suppose that the set of string that match our regex are sorted in a lexicographical order, how could we get the i element of this list ? Edit : I added this simple example for more explanation : input : regex="[a-c]{1,2}"; index=4; in this case the ordered list of string that matches this regex contains those elements : a aa ab ac b ba bb bc c ca cb cc output : the 4th element which is ac ps: it's known that the string list that match the regex have infinite element, this doesn't have an impact on the proccess of extracting the element in the given index.

    Read the article

  • Java regex replace multiple file paths in a large String

    - by Joe Goble
    So a Regex pro I am not, and I'm looking for a good way to do this. I have a large string which contains a variable number <img> tags. I need to change the path on all of these images to images/. The large string also contains other stuff not just these img's. <img src='http://server.com/stuff1/img1.jpg' /> <img src='http://server.com/stuff2/img2.png' /> Replacing the server name with a ReplaceAll() I could do, it's the variable path in the middle I'm clueless on how to include. It doesn't necessarily need to be a regex, but looping through the entire string just seems wasteful.

    Read the article

  • Javascript Regex multiple group matches in pattern

    - by mummybot
    I have a question for a Javascript regex ninja: How could I simplify my variable creation from a string using regex? I currently have it working without using any grouping, but I would love to see a better way! The string is: var url = 'resources/css/main.css?detect=#information{width:300px;}'; The code that works is: var styleStr = /[^=]+$/.exec(url).toString(); var id = /[^\#][^\{]+/.exec(styleStr).toString(); var property = /[^\{]+/.exec(/[^\#\w][^\:]+/.exec(styleStr)).toString(); var value = /[^\:]+/.exec(/[^\#\w\{][^\:]+[^\;\}]/.exec(styleStr)).toString(); This gives: alert(id) //information alert(property) //width alert(value) //300px Any takers?

    Read the article

  • Regex Question..

    - by Josh
    Hello everyone- In my C# Console App I'm trying to use Regex to search a string to determine if there is a match or not. Below is my code but it is not quite working right so I will explain further. sSearchString is set to "_One-Call_Pipeline_Locations" and pDS.Name is a filename it is searching against. Using the code below it is set to true for Nevada_One-Call_Pipeline_Locations and Nevada_One-Call_Pipeline_LocationsMAXIMUM. There should be a match for Nevada_One-Call_Pipeline_Locations But Not for Nevada_One-Call_Pipeline_LocationsMAXIMUM. How can I change my code to do this properly? Thanks in advance if (Regex.IsMatch(pDS.Name, sSearchString))

    Read the article

  • How to match this with a regex?

    - by andrei miko
    I just wanna use a regex to match something from my products file. I have them in this way "Something here","a link here","website here","date here(eg. 11/12/2012)","description1 here","**description2 here**","some other text here","here also", and so on ... I wanna match with a regex only description 2. I tried this: (?<=[0-9][0-9][0-9][0-9]).*(?=",") but it wasn't good because it was getting me description1, description2 and some quotes also. Thanks in advance.

    Read the article

  • Regex Remove Images with style tag from Html

    - by Mark Milford
    Hi I am new to Regex, however I decided it was the easiest route to what I needed to do. Basically I have a string (in PHP) which contains a whole load of HTML code... I want to remove any tags which have style=display:none... so for example <img src="" style="display:none" /> <img src="" style="width:11px;display: none" > etc... So far my Regex is: <img.*style=.*display.*:.*none;.* > But that seems to leave bits of html behind and also take the next element away when used in php with preg_replace.

    Read the article

  • Regex expression with leading zero

    - by user1874087
    I'm rather new to regex expressions and need help with a simple expression. I'm using Pentaho for ETL (Replace in String transformation) and I have column values that I need to add leading zeros to and parse out text as part of the database import. So far I have been unable to add the leading zero. The column is called Region and the values are "region 8", "region 10", "region 11". My regex expression is ['Region'] which will eliminate the region text but produces results = "8", "10", "11". I need values to produce "08", "10", "11". So all the single digit numbers must have leading zeros.

    Read the article

  • RegEx (or other) parsing of script

    - by jpmyob
    RegEx is powerful - it is tru but I have a little - query for you I want to parse out the FUNCTIONS from some old code in JS...however - I am RegEx handicapped (mentally deficient in grasping the subtleties).. the issue that makes me NOT EVEN TRY - is two fold - 1) myVar = function(x){ yadda yadda } AND function myVar(x) { yadda yadda } are found throuout - COLD I write a parser for each? sure - but that seems inefficient... 2) MANY things may reside INSIDE the {} including OTHER sets of {} or other Functions(){} block of text... HELP - does anyone have, or know of some code parsing snippets or examples that will parse out the info I want to collect? Thanks

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >