Search Results

Search found 4539 results on 182 pages for 'regex grouping'.

Page 5/182 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Case insensitive Regex without using RegexOptions enumeration

    - by spoon16
    Is it possible to do a case insensitive match in C# using the Regex class without setting the RegexOptions.IgnoreCase flag? What I would like to be able to do is within the regex itself define whether or not I want the match operation to be done in a case insensitive manner. I would like this regex, taylor, to match on the following values: Taylor taylor taYloR

    Read the article

  • Regex, encoding, and characters that look a like

    - by hack.augusto
    First, a brief example, let's say I have this "/[0-9]{2}°/" regex and this text "24º". The text won't match, obviusly ... (?) really, it depends on the character encoding. Here is my problem, I do not have control on which chars the user uses, so, I need to cover all possibilities in the regex /[0-9]{2}[°º]/, or even better, assure that the text has only the chars I'm expecting °. But I can't just remove the unknow chars otherwise the regex won't work, I need to change it to the chars that looks like it and I'm expecting. I have done this through a little function that maps the "look like" to "what I expect" and change it, the problem is, I have not covered all possibilities, for example, today I found a new "-", now we got three of them, just like latex =D - -- --- ,cool , but the regex didn't work. Does anyone knows how I might solve this?

    Read the article

  • Use regex in awk command in bash script

    - by fmpdmb
    I'm trying to read a file of regexes, looping over them and filtering them out of another file. I'm so close, but I'm having issues with my $regex var substitution I believe. while read regex do awk -vRS= '!/$regex/' ORS="\n\n" $tempOne > $tempTwo mv $tempTwo $tempOne done < $filterFile $tempOne and $tempTwo are temporary files. $filterFile is the file containing the regexes.

    Read the article

  • URL regex search and replace on MySQL (in WordPress)

    - by Tal Galili
    Hello all, I have a WordPress blog with numerous URL's I wish to replace from this: http://www.oldwebsite.co.il/name/*.asp To this: http://www.newwebsite.com/?p=* For example, from this: http://oldwebsite.co.il/name/65971.asp To this: http://www.newwebsite.com/?p=65971 I believe the following plugin: http://urbangiraffe.com/plugins/search-regex/ will do the trick with regex, but I am looking for the correct regex to use here. I found this stackoverflow thread that has a similar task, but since I am not too apt with regex, I was hoping for help so I don't mess anything up. Thanks, Tal After searching stackoverflow, I found

    Read the article

  • Regex expresion in MS SQL

    - by adopilot
    I do not not know much about Regex, I want to try parsing sting from database according to flowing instructions. I know that I am need to use CLR but for begin I want to learn Regex Data in tables look like create table #tempTBL (opis varchar(40)) go insert into #tempTBL select 'C 136' union select 'C 145' union select 'C146' union select 'AK C 182' union select 'C 277' union select 'C-240' union select 'ISPRAVKA PO C 241' And select sting looks like Select reverse( rtrim( ltrim( replace( (substring (reverse(opis) ,0 ,charindex( 'C',reverse(opis) ) ) ) ,'-',' ') ) ) ) as jci from #tempTBL How should looks like my C# code to I repeat this using regex

    Read the article

  • LookAhead Regex in .Net - unexpected result

    - by AaronM
    Hello, I am a bit puzzled with my Regex results (and still trying to get my head around the syntax). I have been using http://regexpal.com/ to test out my expression, and its works as intended there, however in C# its not as expected. Here is a test - an expression of the following: (?=<open>).*?(?=</open>) on an input string of: <open>Text 1 </open>Text 2 <open>Text 3 </open>Text 4 <open>Text 5 </open> I would expect a result back of <open>Text1 <open>Text 2 <open>Text 3... etc However when I do this in C# it only returns the first match of <open>Text1 How do I get all five 'results' back from the Regex? Regex exx = new Regex("(?=<open>).*?(?=</open>)", RegexOptions.IgnoreCase | RegexOptions.Singleline); string input = "<open>Text 1</open> Text 2 <open> Text 3 </open> Text 4 <open> Text 5 </open>"; string result = Regex.Match(input, exx.ToString(), exx.Options).ToString();

    Read the article

  • Perl : get substring which matches regex error

    - by Michael Mao
    I am very new to Perl, so please bear with my simple question: Here is the sample output: Most successful agents in the Emarket climate are (in order of success): 1. agent10896761 ($-8008) 2. flightsandroomsonly ($-10102) 3. agent10479475hv ($-10663) Most successful agents in the Emarket climate are (in order of success): 1. agent10896761 ($-7142) 2. agent10479475hv ($-8982) 3. flightsandroomsonly ($-9124) I am interested only in agent names as well as their corresponding balances, so I am hoping to get the following output: agent10896761 -8008 flightsandroomsonly -10102 agent10479475hv -10663 agent10896761 -7142 agent10479475hv -8982 flightsandroomsonly -9124 For later processes. This is the code I've got so far: #!/usr/bin/perl -w open(MYINPUTFILE, $ARGV[0]); while(<MYINPUTFILE>) { my($line) = $_; chomp($line); # regex match test if($line =~ m/agent10479475/) { if($line =~ m/($-[0-9]+)/) { print "$1\n"; } } if($line =~ m/flightsandroomsonly/) { print "$line\n"; } } The second regex match has nothing wrong, 'cause that is printing out the whole line. However, for the first regex match, I've got some other output such like: $ ./compareResults.pl 3.txt 2. flightsandroomsonly ($-10102) 0479475 0479475 3. flightsandroomsonly ($-9124) 1. flightsandroomsonly ($-8053) 0479475 1. flightsandroomsonly ($-6126) 0479475 If I "escape" the braces like this if($line =~ m/\($-[0-9]+\)/) { print "$1\n"; } Then there is never a match for the first regex... So I'm stuck with a problem of making that particular regex work. Any hints for this? Many thanks in advance.

    Read the article

  • regex matches with intersection in C#

    - by StuffHappens
    Hello. I wonder if it is possible to get MatchCollection with all matches even if there's intersection among them. string input = "a a a"; Regex regex = new Regex("a a"); MatchCollection matches = regex.Matches(input); Console.WriteLine(matches.Count); This code return 1, but I want it to return 2. How do achive it? Thank you for your help.

    Read the article

  • Regex pattern failing

    - by Scott Chamberlain
    I am trying to strip out all things that are in a string that are not a letter number or space so I created the regex private static Regex _NonAlphaChars = new Regex("[^[A-Za-z0-9 ]]", RegexOptions.Compiled); however When I call _NonAlphaChars.Replace("Scott,", ""); it returns "Scott," What am I doing wrong that it is not matching the ,?

    Read the article

  • Generating a list of values a regex COULD match in Python

    - by mlissner
    I'm trying to use a regex as an input, and from there generate all the possible values that the regex would match. So, for example, if the regex is "three-letter words starting with a, and ending in c," then the code would generate a list with the values [aac, abc, acc, adc, a1c....]. Is there an easy way to do this? I'm using python.

    Read the article

  • regex substring C#

    - by sharma
    Hi, I need help to figure the regex expression I have string = "STATE changed from [Fixed] to [Closed], CLOSED DATE added [Fri Jan 14 09:32:19 MST 2011], NOTES changed from [CLOSED[]<br />] to [TEST CLOSED <br />]" I need to grab NOTES changed from [CLOSED[]<br />] to [TEST CLOSED <br />] and take values CLOSED[] and TEST CLOSED in two string variables. So far I got to: Regex NotesChanged = new Regex(@"NOTES changed from \[(\w*|\W*)\] to \[([\w-|\W-]*)\]"); which matches only if "NOTES changed from" started at the beginning and has no '[]' within '[ ]', but I have "[CLOSED[]]" and also no "". Any ideas on what to change in regex. Thanks, Sharma

    Read the article

  • Help with C++ Boost::regex

    - by Youssef
    Hello everybody, I'm trying to get all words inside a string using Boost::regex in C++. Here's my input : "Hello there | network - bla bla hoho" using this code : regex rgx("[a-z]+",boost::regex::perl|boost::regex::icase); regex_search(input, result, rgx); for(unsigned int j=0; j I only get the first word "Hello".. whats wrong with my code ? result.size() returns 1. thank you.

    Read the article

  • Regex: Use start of line/end of line signs (^ or $) in different context

    - by fgysin
    While doing some small regex task I came upon this problem. I have a string that is a list of tags that looks e.g like this: foo,bar,qux,garp,wobble,thud What I needed to do was to check if a certain tag, e.g. 'garp' was in this list. (What it finally matches is not really important, just if there is a match or not.) My first and a bit stupid try at this was to use the following regex: [^,]garp[,$] My idea was that before 'garp' there should either be the start of the line/string or a comma, after 'garp' there should be either a comma or the end of the line/string. Now, it is instantly obvious that this regex is wrong: Both ^ and $ change their behaviour in the context of the character class [ ]. What I finally came up with is the following: ^garp$|^garp,|,garp,|,garp$ This regex just handles the 4 cases one by one. (Tag at beginning of list, in the center, at the end, or as the only element of the list.) The last regex is somehow a bit ugly in my eyes and just for funs sake I'd like to make it a bit more elegant. Is there a way how the start of line/end of line characters (^ and $) can be used in the context of character classes?

    Read the article

  • What's wrong with this regex (VBScript/Javascript flavor)

    - by OtherMichael
    I'm trying to run a regular expression in VBA code that uses Microsoft VBScript Regular Expressions 5.5 (should be the same as JavaScript regex) regex: ^[0-9A-Z]?[0-9A-Z]{3}[A-Z]?([0-9A-Z]{6})-?([0-9])?$ input: X123A1234567 match: 123456 the six characters I'm interested in give a good match of 123456, ignoring the last (check) digit. Perfect. (The check digit is captured, but it's not a major concern to me). But when BOTH the optional portions are gone (they are optional) the match grabs the last digit GOOD input: 123A1234567 match: 123456 Leave in the optional middle alpha, take out the optional leading alpha, and we still get the good match of 123456 GOOD input: X1231234567 match: 123456 Leave in the optional leading alpha, take out the middle optional alpha, and we still get a good match of 123456 BAD input: 1231234567 match: 234567 Take out BOTH optional alphas, and we get a bad match of 234567 Have a looksee @ the regex testers on http://www.regular-expressions.info/javascriptexample.html or http://www.regular-expressions.info/vbscriptexample.html What am I missing, here? How can I get the regex to ignore the last digit when both optional alphas are missing? The regex is used to feed a lookup system, so that no matter what format the input data, we can match to a complete value.

    Read the article

  • How to write this in different regex flavours

    - by taspeotis
    I have the following data: a b c d FROM:<uniquepattern1> e f g h TO:<uniquepattern2> i j k l FROM:<uniquepattern1> m n o p TO:<uniquepattern3> q r s t FROM:<uniquepattern4> u v w x TO:<uniquepattern5> I would like a regex query that can find the contents of TO: when FROM:<uniquepattern1> is encountered, so the results would be uniquepattern2 and uniquepattern3. I am hopeless with regex, I would appreciate any pointers on how to write this (lookahead parameters?) and any differences between regex on different platforms (eg the C# .NET Regex versus Grep vs Perl) that might be relevant here. Thank you.

    Read the article

  • Adding "Max Length" to Regex

    - by SeToY
    How can I extend already present Regex's with an attribute telling that the regex can't exceed a maximum length of (let's say) 255? I've got the following regex: ([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?) I've tried it like that, but failed: {.,255([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)}

    Read the article

  • Using Regex to remove script tags

    - by amitre
    Hi, I'm trying to use a Regex expression I've found in this website and it doesn't seem to work. Any ideas? Input string: sFetch = "123<script type=\"text/javascript\">\n\t\tfunction utmx_section(){}function utmx(){}\n\t\t(function()})();\n\t</script>456"; Regex: sFetch = Regex.Replace(sFetch, "<script.*?>.*?</script>", "", RegexOptions.IgnoreCase); Thanks!!!

    Read the article

  • Regex solution for Objective-C

    - by rjstelling
    What is the best method for using Regular Expressions within Objective-C? There seems to be some open source project that provide regex support, can any one recommend one? Also I looked at NSPredicate, can anyone suggest any regex examples? Background: I want use regex mainly for validation, IP's, email addresses, internal ID's etc

    Read the article

  • How to outperform this regex replacement?

    - by spender
    After considerable measurement, I have identified a hotspot in one of our windows services that I'd like to optimize. We are processing strings that may have multiple consecutive spaces in it, and we'd like to reduce to only single spaces. We use a static compiled regex for this task: private static readonly Regex regex_select_all_multiple_whitespace_chars = new Regex(@"\s+",RegexOptions.Compiled); and then use it as follows: var cleanString= regex_select_all_multiple_whitespace_chars.Replace(dirtyString.Trim(), " "); This line is being invoked several million times, and is proving to be fairly intensive. I've tried to write something better, but I'm stumped. Given the fairly modest processing requirements of the regex, surely there's something faster. Could unsafe processing with pointers speed things further?

    Read the article

  • Remove characters with regex in c#

    - by Rise_against
    Hello all, I am not a regex specialist, so I need some help with this. I have a text file, and I need to remove some trailing delimiters. The text file looks like this: MSH|^~\&|OAZIS||||20101029135359||ADT^A31|00000015|P|2.3.1||||||ASCII EVN|A31|20101029135359^^^^||||19900101 So I think the best way is to do a Regex replace? Can anyone help me with this regex? I want to remove all ^ that come before a | So test^A^^| has to become test^A| Thanks

    Read the article

  • regex to get current page or directory name?

    - by John Isaacks
    I am trying to get the page or last directory name from a url for example if the url is: http://www.example.com/dir/ i want it to return dir or if the passed url is http://www.example.com/page.php I want it to return page Notice I do not want the trailing slash or file extension. I tried this: $regex = "/.*\.(com|gov|org|net|mil|edu)/([a-z_\-]+).*/i"; $name = strtolower(preg_replace($regex,"$2",$url)); I ran this regex in PHP and it returned nothing. (however I tested the same regex in ActionScript and it worked!) So what am I doing wrong here, how do I get what I want? Thanks!!!

    Read the article

  • Zend RegEx Validator error message issue

    - by Mallika Iyer
    Hello, I'm validating a text field in my form as follows: $name = new Zend_Form_Element_Text('name'); $name->setLabel('First Name:') ->setRequired(true) ->addFilter(new Zend_Filter_StringTrim()) ->addValidator('regex',true,array('/^[(a-zA-Z0-9)]+$/')) ->addErrorMessage('Please enter a valid first name'); What I'm trying to accomplish is - how can i display a meaningful error message? Eg: If first name is 'XYZ-', how can i display '- is not allowed in first name.' Is there a way I can access what character the regex is failing for? Would you recommend something else altogether? I thought about writing a custom validator but the regex is pretty simple, so I don't see the point. I couldn't find a decent documentation for the zend 'regex' validator anywhere. If I don't override the default error message, I simple get something like : ';;;hhbhbhb' does not match against pattern '/^[(a-zA-Z0-9)]+$/' - which I obviously don't want to display to the user. I'd appreciate your inputs.

    Read the article

  • Regex For Finding Ctypes with Int32

    - by Stefan H
    (Hey all, I am looking for a little regex help... I am trying to find all CType(expression,Int32) s and replace them with CInt(expression) This, however, is proving quite difficult, considering there could be a nested Ctype(expression, Int32) within the regex match. Does anyone have any ideas for how to best go about doing this? Here is what I have now: Dim str As String = "CType((original.Width * CType((targetSize / CType(original.Height, Single)), Single)), Int32)" Dim exp As New Regex("CType\((.+), Int32\)") str = exp.Replace(str, "CInt($1)") But this will match the entire string and replace it. I was thinking of doing a recursive function to find the outer most match, and then work inwards, but that still presents a problem with things like CType(replaceChars(I), Int32)), Chr(CType(replacementChars(I), Int32) Any tips would be appreciated. Input returnString.Replace(Chr(CType(replaceChars(I), Int32)), Chr(CType(replacementChars(I), Int32))) Output: returnString.Replace(Chr(CInt(replaceChars(I))),Chr(CInt(replacementChars(I)))) Edit: Been working on it a little more and have a recursive function that I'm still working out the kinks in. Recursion + regex. it kinda hurts. Private Function FindReplaceCInts(ByVal strAs As String) As String System.Console.WriteLine(String.Format("Testing : {0}", strAs)) Dim exp As New Regex("CType\((.+), Int32\)") If exp.Match(strAs).Success Then For Each match As Match In exp.Matches(strAs) If exp.Match(match.Value.Substring(2)).Success Then Dim replaceT As String = match.Value.Substring(2) Dim Witht As String = FindReplaceCInts(match.Value.Substring(2)) System.Console.WriteLine(strAs.IndexOf(replaceT)) strAs.Replace(replaceT, Witht) End If Next strAs = exp.Replace(strAs, "CInt($1)") End If Return strAs End Function Cheers,

    Read the article

  • POSIX-compatible regex library for Visual Studio C

    - by user1397061
    I'm working on a C program which will be run in Linux and from inside Visual Studio 2010, and I'm looking for a regex library. GNU comes with a POSIX-compatible regex library, but Visual Studio, despite having C++ std::regex, doesn't have a C-compatible library. GNU has a Windows version of their library (http://gnuwin32.sourceforge.net/packages/regex.htm), but the DLLs are 32-bit only and the source code can't compile in Visual Studio (~500 errors!). My only requirement is that the end-user should not have to install anything extra, and should get the same behaviour on both platforms. I'm not picky about whether it's POSIX-style, Perl-style or something else. What should I do? Thanks in advance.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >