How to extract part of location.href in JavaScript?
In this example, what's the regexp to to extract 'first' from location.href, such as: http://www.mydomain.com/first/ ...
In this example, what's the regexp to to extract 'first' from location.href, such as: http://www.mydomain.com/first/ ...
A buddy of mine is currently tinkering around with JpCap in Java and we found some interesting (maybe?) problem regarding regular expressions in Java. Only HTTP traffic is being captured and subsequently analyzed. For this purpose he is using a pattern like this one: Pattern p = Pattern.compile("(www)"); But what both of us have not ...
I'm not sure it's possible or not, but one of the things I find I need to do often is to replace the contents of the file, but I want to use the current line number as a replacement option. So if I had a file like: This is text to replace XX This is text to replace XX This is text to replace XX I would want to be able to run a rege...
Say I have the string "User Name:firstname.surname" contained in a larger string how can I use a regular expression to just get the firstname.surname part? Every method i have tried returns the string "User Name:firstname.surname" then I have to do a string replace on "User Name:" to an empty string. Could back references be of use her...
I have not been able to write a regular expression, to use in a String.split (Java) expression such as to only split on comma which are not in parentheses. Example: (54654,4565):(45651,65423),4565:45651,(4565,4564):45651 Should yield the 3 strings: (54654,4565):(45651,65423) 4565:45651 (4565,4564):45651 Any help much apprecia...
On our Squid server, the admin has put on a new regex rule: ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ I know that it stands for IP address, but it allows all URLs to go through, only pinging external address has stopped. Also tunneling software like UltraSurf have stopped connecting to the server. Skype also is not getting connected. Please e...
I am using posix c regex library(regcomp/regexec) on my search application. My application supports different languages including those that uses multi-byte characters. I'm encountering a problem when using word boundary metacharacter (\b). For single-byte strings, it works just fine, e.g: "\bpaper\b" matches "paper" However, if the re...
Okay, I barely understand RegEx basics, but why couldn't they design it to use keywords (like SQL) instead of some cryptic wildcard characters and symbols? Is it for performance since the RegEx is interpreted/parsed at runtime? (not compiled) Or maybe for speed of writing? Considering that when you learn some "simple" character combina...
I have a wysiwyg text area in a Java webapp. Users can input text and style it or paste some already HTML-formatted text. What I am trying to do is to linkify the text. This means, converting all possible URLs within text, to their "working counterpart", i.e. adding < a href="...">...< /a>. This solution works when all I have is plain ...
I want to replace all non-alpha characters in a string with a plus '+' sign, but making sure that a group of more than one non-alpha chars is only replaced by one plus sign. I had thought the following might work but apparently not: System.Text.RegularExpressions.Regex.Replace(name, @"[^\w]*?", "+") ...
Im trying to insert literal strings into c++ files using a c# tool, and Im tasked with automatically adding escapes. To start with " => \". However I cannot figure out the regular expression required to transform instances of " to \" public String AddEscapeCharactersForCode(String content) { String escaper = "\\\\"; ...
OK, I've got a long list (about 43,800 lines) of entries and I want to select a subset of this list. The list is in a database and the program that reads the database can use one or more regular expressions. Is it better to use multiple (possibly up to 100 or so) regular expressions in one call to the database program to essentially ...
I was curious of just how much stress AS3 Regular Expression testing can impose on the end-user's pc. Is this something that should be used in moderation, or can most computers handle the exhaustive use of it? ...
This regular expression: <IMG\s([^"'>]+|'[^']*'|"[^"]*")+> seems to process endlessly when given this text <img src=http://www.blahblahblah.com/houses/Images/ single_and_multi/roof/feb09/01_img_trrnjks_vol2009.jpg' /> I would expect it to - not find a match (quickly) - because there is only one single quote in the text. I have ...
Given the following file/directory structure: /photos/1/original/filename1.jpg /photos/1/thumb/filename1.jpg /photos/2/original/filename2.jpg /photos/2/thumb/filename2.jpg /photos/3/original/filename3.jpg /photos/3/thumb/filename3.jpg ...etc. I'm looking for the regexp to convert the file/directory structure to: /photos/1/original.jp...
As part of a project for school, I need to replace a string from the form: 5 * x^3 - 6 * x^1 + 1 to something like: 5x<sup>3</sup> - 6x<sup>1</sup> + 1 I believe this can be done with regular expressions, but I don't know how to do it yet. Can you lend me a hand? P.S. The actual assignment is to implement a Polynomial Processing...
I've got a list of email addresses belonging to several domains. I'd like a regex that will match addresses belonging to three specific domains (for this example: foo, bar, & baz) So these would match: a@foo a@bar b@baz This would not: a@fnord Ideally, these would not match either (though it's not critical for this particular pr...
I'd like a Regular Expression for C# that matches "Johnson", "Del Sol", or "Del La Range"; in other words, it should match words with spaces in the middle but no space at the start or at the end. ...
I'm using Mod Rewrite for IIS 7.0 from iis.net and want to redirect requests: http://example.com/users/foo to http://example.com/User.aspx?name=foo http://example.com/users/1 to http://example.com/User.aspx?id=1 I have created 2 rules: <rule name="ID"> <match url="/users/([0-9])" /> <action type="Rewrite" url="/User.aspx?id={R...
Hi Folks - Im not quite sure if this is possible, so I turn to you. I would like to find a regex that will pick out all commas that fall outside quotesets. For example: 'foo' => 'bar', 'foofoo' => 'bar,bar' this would pick out the single comma on line 1, after "'bar'," I don't really care about single vs double quotes. Has anyone...