Search Results

Search found 9016 results on 361 pages for 'regex libraries'.

Page 9/361 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Isolate SQL field using regex

    - by Das123
    I'm trying to isolate a specific field in a SQL dump file so I can edit it but I'm not having any luck. The regex I'm using is: ^(?:(?:'[^\r\n']*'|[^,\r\n]*),){6}('[^\r\n']*'|[^,\r\n]*) Which is supposed to grab the seventh field and place it inside reference 1. The trouble is that this is stumbling when ever it finds a comma inside a text field and counts the partial match as the allowable matches. Eg. (1, 'Title', 1, 3, '2006-09-29', 'Commas, the bane of my regex', 'This is the target', 2, 4) matches " the bane of my regex'" instead of "'This is the target'".

    Read the article

  • Regex for capturing numbered text list

    - by crunchyt
    I have a test list that I am trying to capture data from using a regex. Here is a sample of the text format: (1) this is a sample string /(2) something strange /(3) another bit of text /(4) the last one/ something!/ I have a Regex that currently captures this correctly, but I am having some difficulty with making it work under outlier conditions. Here is my regex /\(?\d\d?\)([^\)]+)(\/|\z)/ Unfortunately some of the data contains parentheses like this: (1) this is a sample string (1998-1999) /(2) something strange (blah) /(3) another bit of text /(4) the last one/ something!/ The substrings '(1998-1999)' and '(blah)' make it fail! Anyone care to have a crack at this one? Thank you :D

    Read the article

  • bash rename using regex array substitution

    - by mulllhausen
    hi, i have a very similar question as for this post. i would like to know how to rename occurances within a filename with designated substitutions. for example if the original file is called: 'the quick brown quick brown fox.avi' i would like to rename it to 'the slow red slow red fox.avi'. i tried this: new="(quick=>'slow',brown=>'red')" regex="quick|brown" rename -v "s/($regex)/$new{$1}/g" * but no love :( i also tried with regex="qr/quick|brown/" but this just gives errors. any idea what im doing wrong?

    Read the article

  • Regex to extract link

    - by Derin
    Hi, I'm looking for a regex to extract links from a url. The url would be as below: /redirecturl?u=http://www.abc.com/&amp;tkn=Ue4uhv&amp;ui=fWrQfyg46CADA&amp;scr=SSTYQFjAA&amp;mk=4D6GHGLfbQwETR I need to extract the link http://www.abc.com from the above url. I tried the regex: redirecturl\\?u=(?<link>[^\"]+)& This works, but the problem is that it does not truncate all the characters after the first occurrence of &. It would be great if you could modify the regex so that I just get the link. Thanks in advance.

    Read the article

  • Problems with matching emails with regex

    - by Gandalf StormCrow
    Hello, I'm trying to match an email address here is what I've come up with so far : String text = "[email protected]"; String regex = "(\\w+)@{1}(\\w+){2,}\\.{1}\\w{2,4}"; This however works with following cases : [email protected] [email protected] [email protected] So it matches any alphanumeric character repeated once or more that comes before one @ followed by any alphanumeric character repeated at least two times(which is minimal characters for any domain name) followed by one .(dot) and followed by any alphanumeric character repeated at least 2 times and at most 4 times(because there are domains such as .us or .mobi). This expression however does not work with emails such as : [email protected] [email protected] [email protected] [email protected] etc as many subdomains or [email protected] [email protected] [email protected] [email protected] I've just started to learn regex and I found interesting to try to solve problems such as these by using regex .. not partially but for each case, any help would be much appriciated. Thank you

    Read the article

  • codingBat last2 using regex

    - by polygenelubricants
    Okay guys, this is similar to my repeatEnd and wordEnds efforts; I want to solve this codingBat Warmup-2 question using only regex-based techniques as a "brain gymnastics" exercise. This solution works for codingBat tests: public int last2(String str) { return str.isEmpty() ? 0 : str.split( str.replaceAll( ".*(.)(.)", "$1(?=$2)" //.replaceAll("(\\$.)", "\\\\\\\\Q$1\\\\\\\\E") ), -1 ).length - 1 - 1; } The monstrous octo-slashes aren't needed to pass codingBat, but is needed for a proper regex-based solution. That is, if I want this (and I do!): assert last2("..+++...++") == 2; I'd have to uncomment the second .replaceAll. I'm just wondering if others can come up with a simpler, more elegant regex solution for this problem. Preferably one that doesn't contain octo-slashes.

    Read the article

  • Regex pattern problem in python

    - by mridang
    I need to extract parts of a string using regex in Python. I'm good with basic regex but I'm terrible at lookarounds. I've shown two sample records below. The last big is always a currency field e.g. in the first one it is 4,76. In the second one it is 2,00. The second has an account number that is the pattern of \d{6}-\d{6}. Anything after that is the currency. 24.02 24.02VALINTATALO MEGAHERTSI4,76- 24.02 24.02DOE MRIDANG 157235-1234582,00- Could you help me out with this regex? What I've written so far is given below but it considers everything after the 'dash' in the account number to be the currency. .*?(\d\d\.\d\d)(.*?)\s*(?<!\d{6}-\d{6})(\d*,\d\d) Thanks in advance

    Read the article

  • Match multiline regex in file object

    - by williamx
    How can I extract the groups from this regex from a file object (data.txt)? import numpy as np import re import os ifile = open("data.txt",'r') # Regex pattern pattern = re.compile(r""" ^Time:(\d{2}:\d{2}:\d{2}) # Time: 12:34:56 at beginning of line \r{2} # Two carriage return \D+ # 1 or more non-digits storeU=(\d+\.\d+) \s uIx=(\d+) \s storeI=(-?\d+.\d+) \s iIx=(\d+) \s avgCI=(-?\d+.\d+) """, re.VERBOSE | re.MULTILINE) time = []; for line in ifile: match = re.search(pattern, line) if match: time.append(match.group(1)) The problem in the last part of the code, is that I iterate line by line, which obviously doesn't work with multiline regex. I have tried to use pattern.finditer(ifile) like this: for match in pattern.finditer(ifile): print match ... just to see if it works, but the finditer method requires a string or buffer. I have also tried this method, but can't get it to work matches = [m.groups() for m in pattern.finditer(ifile)] Any idea?

    Read the article

  • Regex to match the first file in a rar archive file set in Python

    - by mridang
    I need to uncompress all the files in a directory and for this I need to find the first file in the set. I'm currently doing this using a bunch of if statements and loops. Can i do this this using regex? Here's a list of files that i need to match: yes.rar yes.part1.rar yes.part01.rar yes.part001.rar yes.r01 yes.r001 These should NOT be matched: no.part2.rar no.part02.rar no.part002.rar no.part011.rar no.r002 no.r02 I found a similar regex on this thread but it seems that Python doesn't support varible length lookarounds. A single line regex would be complicated but I'll document it well and it's not a problem. It's just one of those problems you beat your heap up, over. Thanks in advance guys. :)

    Read the article

  • regex : how to eliminiate urls ending with .dtd

    - by dorelal
    This is JavaScript regex. regex = /(http:\/\/[^\s]*)/g; text = "I have http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd and I like http://google.com a lot"; matches = text.match(regex); console.log(matches); I get both the urls in the result. However I want to eliminate all the urls ending with .dtd . How do I do that? Note that I am saying ending with .dtd should be removed. It means a url like http://a.dtd.google.com should pass .

    Read the article

  • Regex for tollfree numbers in java

    - by arinte
    I have this regex to test for telephone # that should be a toll free. public static final Pattern patternTollFree = Pattern.compile("^((877)|(800)|(866)|(888))"); So I only want to get those # where the user may have left the 1 off of the front of the string, but I have tried several things and I can't get java to match. public String changeRingTo( String changedRinger ) { if ( null == changedRinger || changedRinger.length() != 10) return changedRinger; if ( patternTollFree.matcher(changedRinger).region(0, 2).matches() ) changedRinger = '1' + changedRinger; return changedRinger; } I can't get this 2nd test case below to succeed. What am I doing wrong? assertEquals( "Regex not working", "8189091000", of.changeRingTo("8189091000")); assertEquals( "Regex not working", "18769091000", of.changeRingTo("8769091000"));

    Read the article

  • C# Find and Replace RegEx question

    - by fraXis
    Hello, I am starting to get a grip on RegEx thanks to all the great help here on SO with my other questions. But I am still suck on this one: My code is: StreamReader reader = new StreamReader(fDialog.FileName.ToString()); string content = reader.ReadToEnd(); reader.Close(); I am reading in a text file and I want to search for this text and change it (the X and Y value always follow each other in my text file): X17.8Y-1. But this text can also be X16.1Y2.3 (the values will always be different after X and Y) I want to change it to this X17.8Y-1.G54 or X(value)Y(value)G54 My RegEx statement follows but it is not working. content = Regex.Replace(content, @"(X(?:\d*\.)?\d+)*(Y(?:\d*\.)?\d+)", "$1$2G54"); Can someone please modify it for me so it works and will search for X(wildcard) Y(Wildcard) and replace it with X(value)Y(value)G54? Thanks, Shawn

    Read the article

  • How to use variables with regex?

    - by dontoo
    This is the input string: 23x^45*y or 2x^2 or y^4*x^3. I am matching ^[0-9]+ after letter x. In other words I am matching x followed by ^ followed by numbers. Problem is that I don't know that I am matching x, it could be any letter that I stored as variable in my char array. For example: foreach (char cEle in myarray) // cEle is letter in char array x, y, z, ... { match CEle in regex(input) //PSEUDOCODE } I am new to regex and I new that this can be done if I define regex variables, but I don't know how.

    Read the article

  • RegEx - Take all numeric characters following a text character

    - by Simon
    Given a string in the format: XXX999999v99 (where X is any alpha character and v is any numeric character and v is a literal v character) how can I get a regex to match the numeric characters following the v? So far I've got 'v\d\d' which includes the v but ideally I'd like just the numeric part. As an aside does anyone know of a tool in which you can specify a string to match and have the regex generated? Modifying an existing regex is one thing but I find starting from scratch painful! Edit: Re-reading this question I realise it reads like a homework assignment! However I can assure you it's not, the strings I'm trying to match represent product versions appended to product codes. The current code uses all sorts of substring expressions to retrieve the version part.

    Read the article

  • Regex replace help

    - by Jeremy
    Using the .NET framework, I'm trying to replace double slash characters in a string with a single slash, but it seems to be removing an extra character and I don't know why. I have a string: http://localhost:4170/RCRSelfRegistration//Default.aspx My regex is: [^(://|:\\\\)](\\\\|//|\\/|/\\) And the return value is: http://localhost:4170/RCRSelfRegistratio/Default.aspx You can see that the n in RCRSelfRegistration has been removed. I am not sure why. /// <summary> /// Match on double slashes (//, \\, /\, \/) but do not match :// or :\\ /// </summary> private const string strMATCH = @"[^(://|:\\\\)](\\\\|//|\\/|/\\)"; /// <summary> /// Replace double slashes with single slash /// </summary> /// <param name="strUrl"></param> /// <returns></returns> public static string GetUrl(string strUrl) { string strNewUrl System.Text.RegularExpressions.Regex rxReplace = new System.Text.RegularExpressions.Regex(strMATCH); strNewUrl = rxReplace.Replace(strUrl, "/"); return strNewUrl; }

    Read the article

  • Regex and PHP for extracting contents between tags with several line breaks

    - by John
    How can I extract the content between tags with several line breaks? I'm a newbie to regex, who would like to know how to handle unknown numbers of line break to match my query. Task: Extract content between <div class="test"> and the first closing </div> tag. Original source: <div class="test">optional text<br/> content<br/> <br/> content<br/> ... content<br/><a href="/url/">Hyperlink</a></div></div></div> I've worked out the below regex, /<div class=\"test\">(.*?)<br\/>(.*?)<\/div>/ Just wonder how to match several line breaks using regex. There is DOM for us but I am not familiar with that.

    Read the article

  • Find and Replace RegEx question

    - by fraXis
    I am starting to get a grip on RegEx thanks to all the great help here on SO with my other questions. But I am still suck on this one: My code is: StreamReader reader = new StreamReader(fDialog.FileName.ToString()); string content = reader.ReadToEnd(); reader.Close(); I am reading in a text file and I want to search for this text and change it (the X and Y value always follow each other in my text file): X17.8Y-1. But this text can also be X16.1Y2.3 (the values will always be different after X and Y) I want to change it to this X17.8Y-1.G54 or X(value)Y(value)G54 My RegEx statement follows but it is not working. content = Regex.Replace(content, @"(X(?:\d*\.)?\d+)*(Y(?:\d*\.)?\d+)", "$1$2G54"); Can someone please modify it for me so it works and will search for X(wildcard) Y(Wildcard) and replace it with X(value)Y(value)G54?

    Read the article

  • what perl regex should I use to get value from line

    - by Octopus
    I am trying to capture the cpu usage from the running process. For SunOS, I have below output process,10050,user1,218,59,0,1271M,1260M,sleep,58.9H,0.02%,java here the cpu % is at 11th field if we separate by comma(,). To get this value I am using below regex regex => q/^process,(?:.*?),((?:\d+)\.(?:\d+))%,java$/, but for the linux system I have below output. process,26190,user1,20,0,1236m,43m,6436,S,0.0,1.1,0:00.00,java, here the cpu usage is at 10th column What regex pattern should i use to get this value. Appreciate for any suggestion.

    Read the article

  • C++: posix regex error reporting?

    - by Helltone
    I'm writing a small C++ program that parses some strings. I chose to use C's regex.h because I only need POSIX Extended Syntax and I'm concerned with portability. However, I've just noticed that when regexec fails to match, it returns != 0 and I have no idea of what was wrong :-(. I expected to be able to display at least a small message like: line:col: Syntax error or giig sdoigosdigo* sodfg ^ Syntax error Is there a way to know which character did not match? Should I use boost:regex instead? For reference, my regex is: "^" "[ ;\t\n]*" "(" // (1) identifier "[a-zA-Z_][a-zA-Z0-9_]*" ")" "[ \t]*" "(" // (2) non-marking "\[" "(" // (3) non-marking "[ \t]*" "(" // (4..n-1) argument "[a-zA-Z0-9_]+" ")" "[ \t]*" "," ")*" "[ \t]*" "(" // (n) last argument "[a-zA-Z0-9_]+" ")" "]" ")?" "[ \t\n]*" ";" Which matches for instance blablabla[arg1, arg2];

    Read the article

  • Regex for splitting a german address into its parts

    - by Christian
    Good evening, I'm trying to splitting the parts of a german address string into its parts via Java. Does anyone know a regex or a library to do this? To split it like the following: Name der Straße 25a 88489 Teststadt to Name der Straße|25a|88489|Teststadt or Teststr. 3 88489 Beispielort (Großer Kreis) to Teststr.|3|88489|Beispielort (Großer Kreis) It would be perfect if the system / regex would still work if parts like the zip code or the city are missing. Is there any regex or library out there with which I could archive this? EDIT: Rule for german addresses: Street: Characters, numbers and spaces House no: Number and any characters (or space) until a series of numbers (zip) (at least in these examples) Zip: 5 digits Place or City: The rest maybe also with spaces, commas or braces

    Read the article

  • Parsing complex string using regex

    - by wojtek_z
    My regex skills are not very good and recently a new data element has thrown my parser into a loop Take the following string "+USER=Bob Smith-GROUP=Admin+FUNCTION=Read/FUNCTION=Write" Previously I had the following for my regex : [+\\-/] Which would turn the result into USER=Bob Smith GROUP=Admin FUNCTION=Read FUNCTION=Write FUNCTION=Read But now I have values with dashes in them which is causing bad output New string looks like "+USER=Bob Smith-GROUP=Admin+FUNCTION=Read/FUNCTION=Write/FUNCTION=Read-Write" Which gives me the following result , and breaks the key = value structure. USER=Bob Smith GROUP=Admin FUNCTION=Read FUNCTION=Write FUNCTION=Read Write Can someone help me formulate a valid regex for handling this or point me to some key / value examples. Basically I need to be able to handle + - / signs in order to get combinations.

    Read the article

  • Matching n parentheses in perl regex

    - by coding_hero
    Hi, I've got some data that I'm parsing in Perl, and will be adding more and more differently formatted data in the near future. What I would like to do is write an easy-to-use function, that I could pass a string and a regex to, and it would return anything in parentheses. It would work something like this (pseudocode): sub parse { $data = shift; $regex = shift; $data =~ eval ("m/$regex/") foreach $x ($1...$n) { push (@ra, $x); } return \@ra; } Then, I could call it like this: @subs = parse ($data, '^"([0-9]+)",([^:]*):(\W+):([A-Z]{3}[0-9]{5}),ID=([0-9]+)'); As you can see, there's a couple of issues with this code. I don't know if the eval would work, the 'foreach' definitely wouldn't work, and without knowing how many parentheses there are, I don't know how many times to loop. This is too complicated for split, so if there's another function or possibility that I'm overlooking, let me know. Thanks for your help!

    Read the article

  • replace characters which do not matches the ones in a regex

    - by Cristian Boariu
    Hi, I have this regex: private static final String SPACE_PATH_REGEX ="[a-z|A-Z|0-9|\\/|\\-|\\_|\\+]+"; I check if my string matches these regex and IF NOT, i want to replace all characters which are not here, with "_". I;ve tried like: private static final String SPACE_PATH_REGEX_EXCLUDE ="[~a-z|A-Z|0-9|\\/|\\-|\\_|\\+]+"; if (myCompanyName.matches(SPACE_PATH_REGEX)) { myNewCompanySpaceName = myCompanyName; } else{ myNewCompanySpaceName = myCompanyName.replaceAll(SPACE_PATH_REGEX_EXCLUDE, "_"); } but does not work..., so in the 2nd regex "~" seems to not omit the following chars. Any ideea?

    Read the article

  • Regex to find external links from the html file using grep

    - by Amar
    hello, From past few days I'm trying to develop a regex that fetch all the external links from the web pages given to it using grep. Here is my grep command grep -h -o -e "\(\(mailto:\|\(\(ht\|f\)tp\(s\?\)\)\)\://\)\{1\}\(.*\?\)" "/mnt/websites_folder/folder_to_search" -r now the grep seem to return everything after the external links in that given line Example if an html file contain something like this on same line GoogleYahoo then the given grep command return the following result http://www.google.com">Google</a><p><a href='https://yahoo.com'>Yahoo</a></p> the idea here is that if an html file contain more than one links(`irrespective in a,img etc`) in same line then the regex should fetch only the links and not all content of that line I managed to developed the same in rubular.com the regex is as follow ("|')(\b((ht|f)tps?:\/\/)(.*?)\b)("|') with work with the above input but iam not able to replicate the same in grep can anyone help I can't modify the html file so don't ask me to do that neither I can look for each specific tags and check their attributes to to get external links as it addup processing time and my application doesn't demand that Thank You

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >