I think we have a bunch of commented out code in our source, and rather than delete it immediately, we've just left it. Now I would like to do some cleanup.
So assuming that I have a good enough RegEx to find comments (the RegEx below is simple and I could expand on it based on our coding standards), how do I take the results of the fi...
I have a group of lines like the following:
tb-set-node-recipe $vpn1 W2K3_SP2_VPN_SRV
tb-set-node-os $vpn2 I_W2K3_SP2_VPN_SRV
tb-set-node-os $xpcli1 I_XP_SP3_VPN_CLI
tb-set-node-os $xpcli2 I_XP_SP2_VPN_CLI
tb-set-node-os $xpcli3 I_XP_SP1_VPN_CLI
tb-set-node-recipe $ftp1 FC8_KS_FTP_SRV
tb-set-node-os $smb1 XP_...
Within a set of large files, I need to replace all occurrences of "\" with "\\". I'd like to use Perl for this purpose. Right now, I have the following:
perl -spi.bak -e '/s/\\/\\\\/gm' inputFile
This command was suggested to me, but it results in no change to inputFile (except an updated timestamp). Thinking that the problem might ...
Hey all,
So I'm trying to rip URLs from an NSString using RegExKitLite and I came across an odd problem.
NSLog(@"Array: %@", [message componentsMatchedByRegex:@"^(http://)[-a-zA-Z0-9+&@#/%?=~_()|!:,.;]*"]);
NSString *message is just some text with a URL within it. The strange thing is it doesn't work with the ampersand in it. If...
I have an issue where I need to use a RegularExpressionValidator to limit the length of a string to 400 Characters.
My expression was .{0,400}
My question: Is there a way to limit the length of characters to 400 without taking into consideration blank spaces?
I want to be able to accept blank spaces in the string but not count it in t...
Hi, I would like to know how to retrieve all results from each <p> tag.
import re
htmlText = '<p data="5" size="4">item1</p><p size="4">item2</p><p size="4">item3</p>'
print re.match('<p[^>]*size="[0-9]">(.*?)</p>', htmlText).groups()
result:
('item1', )
what I need:
('item1', 'item2', 'item3')
...
I have the simple regular expression:
\{[0-9]*\}
which works fine with PHP's ereg_ functions (Posix compatible), but I need to use the preg_match_all function, which doesn't have an ereg_ equivalent. My expression above doesn't seem to work with preg_ (perl compatible) functions. How can I go about "converting" it to be perl compatibl...
Hi, I have the following bit of code in my htaccess that will allow a users ID to only be alphanumeric and include underscores and hyphens:
RewriteRule ^([A-Za-z0-9_-]+)$ profile.php?ID=$1 [QSA,L]
I've recently imported over 1000 usernames from a social networking platform that allowed usernames to contain special characters, but this...
Hi.
Can someone provide me with a regular expression that will find this string : <%
but will exclude this string : <%@
Thanks.
...
Why are regular expressions called regular expressions?
...
I have the following regex:
s/\\/\\\\/g
This does a nice job of replacing all "\" characters with "\\". However, I want to guard against matching backslashes that are adjacent to other backslashes. If I do this:
s/[^\\]\\[^\\]/\\\\/g
it only catches non-adjacent backslashes. But now there's the obvious problem that the matches i...
Hi all,
I'm a relative newb when it comes to regexes, but i'm starting to get the hang of it. I started writing a method in java to "linkify" a string - that is, scan it for any references of urls (i.e, "http://...") or strings that look like web addresses ("www.example.com...")
So, for example, if I had a string that looked like this...
I'm working on a regular expression (in .Net) that needs to mark subexpressions. Sample inputs are:
EFBCFEyy
EFBQFEyyQ
EFBQFE yy Q
EFBMFEyyMM
EFByyMFEMM
What I need is to pull out all of the sub-expressions delineated by "yy" or "MM". The expression I've got so far works for the first few strings, but not the final pair. There may be...
How would I use regex to split the set-cookie header into name and value:
Eg. test_cookie=Cookie+check; path=/; domain=.Site.com
name: test_cooke
value: Cookie+check; path=/; domain=Site.com
...
I'm attempting something which I feel should be fairly obvious to me but it's not. I'm trying to match a string which does NOT contain a specific sequence of characters. I've tried using [^ab], [^(ab)], etc. to match strings containing no 'a's or 'b's, or only 'a's or only 'b's or 'ba' but not match on 'ab'. The examples I gave won't ...
Ok, I need help. This is my first question here.
Background:
I am working on a charity project, and my portion of the project is to build the Web-To-Case functionality with Salesforce.com. Salesforce.com, if you were unaware, gives its software away free to qualified non-profits. Anyway, the Web-To-Case feature in Salesforce.com ge...
I have a large regular expression and I've turned on IgnorePatternWhitespace so I can make it more readable. My problem is that I want to match a literal space character. What's the best way to do that?
An example:
Regex myRegex = new Regex(@"
(?> <table[^>]*> ) # Find a table
(?> .*?<tr> ) # Find the first row
(?> .*?<th> ) # ...
Hey folks. I'm struggling with a regular expression that will match input in a "single page/page range" text box, meaning the user can enter either a single integer or an integer range in a [lowerBound]-[upperBound] format. For example:
11 : match
2 : match
2-9 : match
2a : not a match
19- : not a match
Is this possible wit...
I'm trying to write a regular expression engine. I'd like to write a recursive descent parser by hand. What would a context-free grammar without left recursion for the language of regular expressions (not the languages that can be described by regular expressions) look like? Would it be easiest to re-factor out the syntactic sugar, i.e. ...
I need to substitute a list of words with with an equally long list of words.
So for example you have:
"a","b","c","d","e","f"
And you want to replace each word with the uppercase version of each word:
"A","B","C","D","E","F"
I know how to find each string using the regex:
(a\|b\|c\|d\|e\|f)
I know you could do a global substitution ...