Search Results

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

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

  • Replace named group in regex

    - by Tomas Voracek
    I want to use regular expression same way as string.Format. I will explain I have: string pattern = "^(?<PREFIX>abc_)(?<ID>[0-9])+(?<POSTFIX>_def)$"; string input = "abc_123_def"; Regex regex = new Regex(pattern, RegexOptions.IgnoreCase); string replacement = "456"; Console.WriteLine(regex.Replace(input, string.Format("${{PREFIX}}{0}${{POSTFIX}}", replacement))); This works, but i must provide "input" to regex.Replace. I do not want that. I want to use pattern for matching but also for creating strings same way as with string format, replacing named group "ID" with value. Is that possible? I'm looking for something like: string pattern = "^(?<PREFIX>abc_)(?<ID>[0-9])+(?<POSTFIX>_def)$"; string result = ReplaceWithFormat(pattern, "ID", 999); Result will contain "abc_999_def". How to accomplish this?

    Read the article

  • C++: what regex library should I use?

    - by Stéphane
    I'm working on a commercial (not open source) C++ project that runs on a linux-based system. I need to do some regex within the C++ code. (I know: I now have 2 problems.) QUESTION: What libraries do people who regularly do regex from C/C++ recommend I look into? A quick search has brought the following to my attention: 1) Boost.Regex (I need to go read the Boost Software License, but this question is not about software licenses) 2) C (not C++) POSIX regex (#include <regex.h>, regcomp, regexec, etc.) 3) http://freshmeat.net/projects/cpp_regex/ (I know nothing about this one; seems to be GPL, therefore not usable on this project) Thanks.

    Read the article

  • Nginx location regex is not matching

    - by shtuff.it
    The following has been working to cache css and js for me: location ~ "^(.*)\.(min.)?(css|js)$" { expires max; } results: $ curl -I http://mysite.com/test.css HTTP/1.1 200 OK Server: nginx Date: Thu, 16 Jan 2014 18:55:28 GMT Content-Type: text/css Content-Length: 19578 Last-Modified: Mon, 13 Jan 2014 18:54:53 GMT Connection: keep-alive Expires: Thu, 31 Dec 2037 23:55:55 GMT Cache-Control: max-age=315360000 X-Backend: stage01 Accept-Ranges: bytes I am trying to get versioning setup for my js / css using a 10 digit unix timestamp and am having issues getting a regex match with the following valid a regex. location ~ "^(.*)([\d]{10})\.(min\.)?(css|js)$" { expires max; } results: $ curl -I http://mysite.com/test_1234567890.css HTTP/1.1 200 OK Server: nginx Date: Thu, 16 Jan 2014 19:05:03 GMT Content-Type: text/css Content-Length: 19578 Last-Modified: Mon, 13 Jan 2014 18:54:53 GMT Connection: keep-alive X-Backend: stage01 Accept-Ranges: bytes

    Read the article

  • Apache mod_proxy_html Substitute: how to re-use part of regex match? (regex variables?)

    - by goober
    Hi all, Have a unique URL-rewriting situation in Apache. I need to be able to take a URL that starts with "\u002f[X]" or '\u002f[X]" Where X is the rest of some URL, and substitute the text "\u002fmeis2\u002f[X] I'm not sure how the Regex works in Apache -- I think it's the same as Perl 5? -- but even then I'm a little unsure how this would be done. My hunch is that it has to do with Regex grouping and then using $1 to pull the variable out, but I'm entirely unfamiliar with this process in Apache. Hoping someone can help -- thanks!

    Read the article

  • C# Find and Replace RegEx with wildcard search and addition of value

    - by fraXis
    Hello, The below code is from my other questions that I have asked here on SO. Everyone has been so helpful and I almost have a grasp with regards to RegEx but I ran into another hurdle. This is what I basically need to do in a nutshell. I need to take this line that is in a text file that I load into my content variable: X17.8Y-1.Z0.1G0H1E1 I need to do a wildcard search for the X value, Y value, Z value, and H value. When I am done, I need this written back to my text file (I know how to create the text file so that is not the problem). X17.8Y-1.G54G0T2 G43Z0.1H1M08 I have code that the kind users here have given me, except I need to create the T value at the end of the first line, and use the value from the H and increment it by 1 for the T value. For example: X17.8Y-1.Z0.1G0H5E1 would translate as: X17.8Y-1.G54G0T6 G43Z0.1H5M08 The T value is 6 because the H value is 5. I have code that does everything (does two RegEx functions and separates the line of code into two new lines and adds some new G values). But I don't know how to add the T value back into the first line and increment it by 1 of the H value. Here is my code: StreamReader reader = new StreamReader(fDialog.FileName.ToString()); string content = reader.ReadToEnd(); reader.Close(); content = Regex.Replace(content, @"X[-\d.]+Y[-\d.]+", "$0G54G0"); content = Regex.Replace(content, @"(Z(?:\d*\.)?\d+)[^H]*G0(H(?:\d*\.)?\d+)\w*", "\nG43$1$2M08"); //This must be created on a new line This code works great at taking: X17.8Y-1.Z0.1G0H5E1 and turning it into: X17.8Y-1.G54G0 G43Z0.1H5M08 but I need it turned into this: X17.8Y-1.G54G0T6 G43Z0.1H5M08 (notice the T value is added to the first line, which is the H value +1 (T = H + 1). Can someone please modify my RegEx statement so I can do this automatically? I tried to combine my two RegEx statements into one line but I failed miserably. Thanks so much, Shawn

    Read the article

  • Can I write this regex in one step?

    - by Marin Doric
    This is the input string "23x +y-34 x + y+21x - 3y2-3x-y+2". I want to surround every '+' and '-' character with whitespaces but only if they are not allready sourrounded from left or right side. So my input string would look like this "23x + y - 34 x + y + 21x - 3y2 - 3x - y + 2". I wrote this code that does the job: Regex reg1 = new Regex(@"\+(?! )|\-(?! )"); input = reg1.Replace(input, delegate(Match m) { return m.Value + " "; }); Regex reg2 = new Regex(@"(?<! )\+|(?<! )\-"); input = reg2.Replace(input, delegate(Match m) { return " " + m.Value; }); explanation: reg1 // Match '+' followed by any character not ' ' (whitespace) or same thing for '-' reg2 // Same thing only that I match '+' or '-' not preceding by ' '(whitespace) delegate 1 and 2 just insert " " before and after m.Value ( match value ) Question is, is there a way to create just one regex and just one delegate? i.e. do this job in one step? I am a new to regex and I want to learn efficient way.

    Read the article

  • Infinite loop in regex in java

    - by carpediem
    Hello, My purpose is to match this kind of different urls: url.com my.url.com my.extended.url.com a.super.extended.url.com and so on... So, I decided to build the regex to have a letter or a number at start and end of the url, and to have a infinite number of "subdomains" with alphanumeric characters and a dot. For example, in "my.extended.url.com", "m" from "my" is the first class of the regex, "m" from "com" is the last class of the regex, and "y.", "extended." and "url." are the second class of the regex. Using the pattern and subject in the code below, I want the find method to return me a false because this url must not match, but it uses 100% of CPU and seems to stay in an infinite loop. String subject = "www.association-belgo-palestinienne-be"; Pattern pattern = Pattern.compile("^[A-Za-z0-9]\\.?([A-Za-z0-9_-]+\\.?)*[A-Za-z0-9]\\.[A-Za-z]{2,6}"); Matcher m = pattern.matcher(subject); System.out.println(" Start"); boolean hasFind = m.find(); System.out.println(" Finish : " + hasFind); Which only prints: Start I can't reproduce the problem using regex testers. Is it normal ? Is the problem coming from my regex ? Could it be due to my Java version (1.6.0_22-b04 / JVM 64 bit 17.1-b03) ? Thanks in advance for helping.

    Read the article

  • How does MatchEvaluator works? ( C# regex replace)

    - by Marin Doric
    This is the input string 23x * y34x2. I want to insert " * " (star surrounded by whitespaces) after every number followed by letter, and after every letter followed by number. So my input string would look like this: 23 * x * y * 34 * x * 2. This is the regex that does the job: @"\d(?=[a-z])|a-z". This is the function that I wrote that inserts the " * ". Regex reg = new Regex(@"\d(?=[a-z])|[a-z](?=\d)"); MatchCollection matchC; matchC = reg.Matches(input); int ii = 1; foreach (Match element in matchC)//foreach match I will find the index of that match { input = input.Insert(element.Index + ii, " * ");//since I' am inserting " * " ( 3 characters ) ii += 3; //I must increment index by 3 } return input; //return modified input My question how to do same job using .net MatchEvaluator? I'am new to regex and don't understand good replacing with MatchEvaluator. This is the code that I tried to wrote: Regex reg = new Regex(@"\d(?=[a-z])|[a-z](?=\d)"); MatchEvaluator matchEval = new MatchEvaluator(ReplaceStar); input = reg.Replace(input, matchEval); return input; } public string ReplaceStar( Match match ) { //return What?? }

    Read the article

  • Automatically generating Regex from set of strings residing in DB C#

    - by Muhammad Adeel Zahid
    Hello Everyone i have about 100,000 strings in database and i want to if there is a way to automatically generate regex pattern from these strings. all of them are alphabetic strings and use set of alphabets from English letters. (X,W,V) is not used for example. is there any function or library that can help me achieve this target in C#. Example Strings are KHTK RAZ given these two strings my target is to generate a regex that allows patterns like (k, kh, kht,khtk, r, ra, raz ) case insensitive of course. i have downloaded and used some C# applications that help in generating regex but that is not useful in my scenario because i want a process in which i sequentially read strings from db and add rules to regex so this regex could be reused later in the application or saved on the disk. i m new to regex patterns and don't know if the thing i m asking is even possible or not. if it is not possible please suggest me some alternate approach. Any help and suggestions are highly appreciated. regards Adeel Zahid

    Read the article

  • Regex with optional part doesn't create backreference

    - by padraigf
    I want to match an optional tag at the end of a line of text. Example input text: The quick brown fox jumps over the lazy dog {tag} I want to match the part in curly-braces and create a back-reference to it. My regex looks like this: ^.*(\{\w+\})? (somewhat simplified, I'm also matching parts before the tag): It matches the lines ok (with and without the tag) but doesn't create a back-reference to the tag. If I remove the '?' character, so regex is: ^.*(\{\w+\}) It creates a back-reference to the tag but then doesn't match lines without the tag. I understood from http://www.regular-expressions.info/refadv.html that the optional operator wouldn't affect the backreference: Round brackets group the regex between them. They capture the text matched by the regex inside them that can be reused in a backreference, and they allow you to apply regex operators to the entire grouped regex. but must've misunderstood something. How do I make the tag part optional and create a back-reference when it exists?

    Read the article

  • Find and Replace RegEx with wildcard search and addition of value

    - by fraXis
    The below code is from my other questions that I have asked here on SO. Everyone has been so helpful and I almost have a grasp with regards to RegEx but I ran into another hurdle. This is what I basically need to do in a nutshell. I need to take this line that is in a text file that I load into my content variable: X17.8Y-1.Z0.1G0H1E1 I need to do a wildcard search for the X value, Y value, Z value, and H value. When I am done, I need this written back to my text file (I know how to create the text file so that is not the problem). X17.8Y-1.G54G0T2 G43Z0.1H1M08 I have code that the kind users here have given me, except I need to create the T value at the end of the first line, and use the value from the H and increment it by 1 for the T value. For example: X17.8Y-1.Z0.1G0H5E1 would translate as: X17.8Y-1.G54G0T6 G43Z0.1H5M08 The T value is 6 because the H value is 5. I have code that does everything (does two RegEx functions and separates the line of code into two new lines and adds some new G values). But I don't know how to add the T value back into the first line and increment it by 1 of the H value. Here is my code: StreamReader reader = new StreamReader(fDialog.FileName.ToString()); string content = reader.ReadToEnd(); reader.Close(); content = Regex.Replace(content, @"X[-\d.]+Y[-\d.]+", "$0G54G0"); content = Regex.Replace(content, @"(Z(?:\d*\.)?\d+)[^H]*G0(H(?:\d*\.)?\d+)\w*", "\nG43$1$2M08"); //This must be created on a new line This code works great at taking: X17.8Y-1.Z0.1G0H5E1 and turning it into: X17.8Y-1.G54G0 G43Z0.1H5M08 but I need it turned into this: X17.8Y-1.G54G0T6 G43Z0.1H5M08 (notice the T value is added to the first line, which is the H value +1 (T = H + 1). Can someone please modify my RegEx statement so I can do this automatically? I tried to combine my two RegEx statements into one line but I failed miserably.

    Read the article

  • "User Friendly" .net compatible Regex/Text matching tools?

    - by Binary Worrier
    Currently in our software we provide a hook where we call a DLL built by our clients to parse information out of documents we are processing (the DLL takes in some text (or a file) and returns a list of name/value pairs). e.g. We're given a Word doc or Text file to Archive. We do various things to the file, and call a DLL that will return "pertinent" information about the file. Among other things we store that "pertinent" data for posterity. What is considered "pertinent" depends on the client and the type of the document, we don't care, we get it and store it. I've been asked to develop a user friendly "something" that will allow a non-programmer user to "configure" how to get this data from a plain text document (<humor>The user story ends with the helpful suggestion/query "We could use regex for this?"</humor>) It's safe to assume that a list of regex's isn't going to cut this, I've written some of these parsers for customers, the regex's to do these would be hedious and some of them can't be done by regex's. Also one of the requirements above is "user friendly" which negates anything that has users seeing or editing regex expressions. As you can guess, I don't have a fortune of time to do this, and am wondering is there anything out there that I can plug in to our app that has a nice front end and does exactly what I need? :) No? Whadda mean no! . . . sigh Ok then failing that, anything out there that "visually" builds regex's and/or other pattern matching expressions, and then allows one to run those expressions against some text? The MS BRE will do what I want, but I need something prettier that looks less like code. Thanks guys,

    Read the article

  • .NET regex: Match.nextMatch() never returns

    - by Jimmy
    I have a regex that seems to have worked fine for the past year or so, and all of a sudden today with a new slightly different text to match against, Match.nextMatch() never returns. I'm no regex expert and I'm sure the regex can be optimized, but previous data sets weren't much more complex than what I've tried today. Furthermore, the regex works fine against the offending data set in a tool like RegexBuddy; it's only in .net (running in debug in Visual Studio) that it seems to hang. Nevertheless, if anyone can figure out how to tweak the regex to make it work, I'd really appreciate it. This is the regex: <tr>(<td[^>]*><a[^>]*>(?<callOptionTicker>[A-Z]{1,5}\d{6}C\d{8})</a></td>)(<td[^>]*>.*?</td>){6}(<td[^>]*><b><a[^>]*>(?<strikePrice>\d*\.\d*)</a></b></td>)(<td[^>]*><a[^>]*>(?<putOptionTicker>[A-Z]{1,5}\d{6}P\d{8})</a></td>) It's meant to extract put and call option tickers from a Yahoo option chain page (i.e., raw HTML). It works fine for IBM http://finance.yahoo.com/q/os?s=IBM&m=2010-05-21 It doesn't work for SPX options (this is the offending data set) http://finance.yahoo.com/q/os?s=I:SPX.W&m=2010-05

    Read the article

  • "You are missing the following 32-bit libraries, and Steam may not run: libc.so.6" The common fixes don't work,

    - by M_Steam_User
    So I know this is a problem that has been asked around a lot, but I've tried a bunch of solutions with no success. I'm running Ubuntu 12.04 (64 bit), and I just installed it yesterday. This is my first time working with linux. The error is: You are missing the following 32-bit libraries, and Steam may not run: libc.so.6 Things I've tried. First, I had downloaded from the steam website. I uninstalled it, and tried again from the ubuntu software centre. sudo apt-get update sudo apt-get install ia32-libs sudo apt-get upgrade This installed a bunch of the 32 bit libraries, but did not fix the issue. This seems like the major fix for most people. The direct approach of sudo apt-get install libc.so.6 returns this: Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package libc.so.6 E: Couldn't find any package by regex 'libc.so.6' I guess libc.so.6 isn't a package, just a single file or something? I also tried gksudo gedit /etc/ld.so.conf.d/steam.conf Added these two lines, those the second one was all ready in the file, but copied over: /usr/lib32 /usr/lib/i386-linux-gnu/mesa Then executed: sudo ldconfig But nothing seemed to happen, steam still doesn't work. So, I feel like it is more likely that I have the library and steam isn't looking in the right place. One thing I've seen is people usually reference /usr/local/lib/ for your library locations. However, I can't find where to cd into /usr/, it isn't in my home folder. If /usr/ is the home folder, there is only a /.local folder which only has /share, no lib anywhere. Sorry for my linux ignorance. I appreciate any help, I honestly have no idea how to confirm I have the library and point steam to it, or if that is even the right thing to do. Edit: Tried this, not entirely sure what it means ~$ ls -l /lib32/libc* -rwxr-xr-x 1 root root 1721832 Sep 30 11:06 /lib32/libc-2.15.so -rw-r--r-- 1 root root 185928 Sep 30 11:06 /lib32/libcidn-2.15.so lrwxrwxrwx 1 root root 15 Sep 30 11:06 /lib32/libcidn.so.1 -> libcidn-2.15.so -rw-r--r-- 1 root root 34316 Sep 30 11:06 /lib32/libcrypt-2.15.so lrwxrwxrwx 1 root root 16 Sep 30 11:06 /lib32/libcrypt.so.1 -> libcrypt-2.15.so lrwxrwxrwx 1 root root 12 Sep 30 11:06 /lib32/libc.so.6 -> libc-2.15.so

    Read the article

  • Injecting jQuery into a page fails when using Google AJAX Libraries API

    - by jakemcgraw
    I'd like to inject jQuery into a page using the Google AJAX Libraries API, I've come up with the following solution: http://my-domain.com/inject-jquery.js: ;((function(){ // Call this function once jQuery is available var func = function() { jQuery("body").prepend('<div>jQuery Rocks!</div>'); }; // Detect if page is already using jQuery if (!window.jQuery) { var done = false; var head = document.getElementsByTagName('head')[0]; var script = document.createElement("script"); script.src = "http://www.google.com/jsapi"; script.onload = script.onreadystatechange = function(){ // Once Google AJAX Libraries API is loaded ... if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) { done = true; // ... load jQuery ... window.google.load("jquery", "1", {callback:function(){ jQuery.noConflict(); // ... jQuery available, fire function. func(); }}); // Prevent IE memory leaking script.onload = script.onreadystatechange = null; head.removeChild(script); } } // Load Google AJAX Libraries API head.appendChild(script); // Page already using jQuery, fire function } else { func(); } })()); The script would then be included in a page on a separate domain: http://some-other-domain.com/page.html: <html> <head> <title>This is my page</title> </head> <body> <h1>This is my page.</h1> <script src="http://my-domain.com/inject-jquery.js"></script> </body> </html> In Firefox 3 I get the following error: Module: 'jquery' must be loaded before DOM onLoad! jsapi (line 16) The error appears to be specific to the Google AJAX Libraries API, as I've seen others use a jQuery bookmarklet to inject jQuery into the current page. My question: Is there a method for injecting the Google AJAX Libraries API / jQuery into a page regardless of the onload/onready state?

    Read the article

  • TeamSpeak3 libraries

    - by Scott
    I've downloaded the TeamSpeak 3 server from their official website (it's 64 bit, as my dedicated server is 64 bit too). This is what I get,when I'm trying to run the server: Starting the TeamSpeak 3 server TeamSpeak 3 server started, for details please view the log file /libexec/ld-elf.so.1: scott# /lib/libiconv.so.3: unsupported file layout Whats wrong? /libexec/ld-elf.so.1 exists, same as the second one, is there any solution for that?

    Read the article

  • TeamSpeak3 libraries

    - by Scott
    I've downloaded the TeamSpeak 3 server from their official website (it's 64 bit, as my dedicated server is 64 bit too). This is what I get,when I'm trying to run the server: Starting the TeamSpeak 3 server TeamSpeak 3 server started, for details please view the log file /libexec/ld-elf.so.1: scott# /lib/libiconv.so.3: unsupported file layout Whats wrong? /libexec/ld-elf.so.1 exists, same as the second one, is there any solution for that?

    Read the article

  • How to do regex HTML tag replace in SQL Server?

    - by timmerk
    I have a table in SQL Server 2005 with hundreds of rows with HTML content. Some of the content has HTML like: <span class=heading-2>Directions</span> where "Directions" changes depending on page name. I need to change all the <span class=heading-2> and </span> tags to <h2> and </h2> tags. I wrote this query to do content changes in the past, but it doesn't work for my current problem because of the ending HTML tag: Update ContentManager Set ContentManager.Content = replace(Cast(ContentManager.Content AS NVARCHAR(Max)), 'old text', 'new text') Does anyone know how I could accomplish the span to h2 replacing purely in T-SQL? Everything I found showed I would have to do CLR integration. Thanks!

    Read the article

  • Separate log files for each web application and shared libraries with log4j

    - by oo_olo_oo
    I have few web applications run on the Tomcat server. Each application contains its own log4j library copy inside its own war. This allows for separate, flexible logging configuration per application. I also have few shared libraries (kept in Tomcat's shared libraries directory). I would like to have shared library loggers output among with the application (which uses them) loggers output (for example: if application A logs to file a.log, and uses library b.jar, I would like b.jar to log also to the a.log file). The problem is, that the shared libraries are loaded by the shared classloader, which causes that they can't access loggers defined by the applications. Is there any solution for this issue?

    Read the article

  • How to add libraries in C++?

    - by m00st
    Yea this is a dumb question... However in both of my C++ classes we did not do this at all (except for native libraries: iostream, iomanip, etc.)... My question is can anyone provide a link that gives the general explanation of adding libraries to C++? I do realize what what #include means; it's just I have no clue on the linker/directories in a C++ IDE. So long question short; could I get a general explanation of terms used to link libraries in C++? I'm using c::b w/ MinGW.

    Read the article

  • Importing libraries in eclipse programmatically

    - by Krt_Malta
    Hi, Is there a way I could put a library (Jar file) into an Eclipse project programatically? Up to now I've managed to do an external reference to it programatically using IPath path = new Path("C:\\Hello\\jtwitter.jar"); libraries.add(JavaCore.newLibraryEntry(path, null, null)); //add libs to project class path try { javaProject.setRawClasspath(libraries.toArray(new IClasspathEntry[libraries.size()]), null); } catch (JavaModelException e1) { e1.printStackTrace(); } } however I'd like to copy the jtwitter file to the project folder programatically so I could reference it as jtwitter.jar only. Can this be done please? Thanks a lot and regards, Krt_Malta

    Read the article

  • Batch-Renaming Movies using Regex

    - by Nate Mara
    So, I've been trying to rename some movie files using regular expressions, but so far I have been only marginally successful. The goal is to parse files like this: 2001.A.Space.Odyssey.1968.720p.BluRay.DD5.1.x264-LiNG.mkv And rename them Like this: 2001 A Space Odyssey (1968).mkv I created the pattern: ^(.+).(\d{4}).+.(mp4|avi|mkv)$ With the output: \1 (\2).\3 Now, this works perfectly fine when I have movies with one-word titles, but when there is more than one word separated by a period, the regex fails to grab anything. What am I doing wrong here?

    Read the article

  • test filenames for regex patterns in bash

    - by rk
    I'm not sure exactly how the code should be written but I want to test a file/folder for naming patterns, something like: if [ -d $i ] && [ regex([0-9].,$i) { do something } I want it to check if the file/folder is a directory and that the name of it is a number (i.e. 1 or 101 or 10007)...

    Read the article

  • Regex in Notepad++ 6

    - by Rocket
    So, Notepad++ got updated to v6.0. One of their new features is PCRE (Perl Compatible Regular Expressions). I tried to use this new feature to find and replace things in a file. I tried the regular expression: {\$([a-zA-Z_]*)} and it yelled at me, saying "Invalid regular expression". I tested this regex in other programs (like my main IDE, Geany), and it worked fine. Why does this not work in Notepad++ 6.0?

    Read the article

  • Implementing Static Libraries In iPhone

    - by socialCircus
    Hi All, I have created a static library following this link. But I am facing Problems in using the library. For reference on how to use static libraries in an iPhone project I followed this link . But I am stil struggling with the "How to implement static libraries in any other iPhone project?" question. Thank you all.

    Read the article

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