regex

What is the simplest way to convert a Java string from all caps (words separated by underscores) to CamelCase (no word separators)?

The title pretty much says it all. What's the simplest/most elegant way that I can convert, in Java, a string from the format "THIS_IS_AN_EXAMPLE_STRING" to the format "ThisIsAnExampleString"? I figure there must be at least one way to do it using String.replaceAll() and a regex, but I've really never understood Java regexes. My initial ...

How to extract a single function from a source file

Hi, I'm working on a small academic research about extremely long and complicated functions in the Linux kernel. I'm trying to figure out if there is a good reason to write 600 or 800 lines-long functions. For that purpose, I would like to find a tool that can extract a function from a .c file, so I can run some automated tests on the ...

Help with regular expression

It's getting towards the end of the day and this is annoying me - one day I'll find the time to learn regex properly as I know it can save a lot of time when extracting info from text. I need to match strings that match the following signature: 6 spaces followed by up 31 alphanumerics (or spaces) and then no more alphanumeric text on t...

Help with regex

Hi just a quick help , i have this line of html -- its ugly: <ul><li><a href="/web3/showProfile.do;jsessionid=812E1C87A4FB4184650C551F27ADADAB.6-1?clientId=ZGVfX05FWFQ-&amp;cid=6-1&amp;activity=userdata&amp;levelFirstItem=0">Zugangsdaten</a></li><li><a href="/web3/setBookingTemplate.do;jsessionid=812E1C87A4FB4184650C551F27ADADAB.6-1?...

Redirect non-www URL to www URL in conjunction with other rules

Redirecting a visitor who hits http://example.com to http://www.example.com isn't terribly difficult. But how is it done in conjunction with a RewriteRule that directs all page requests through "index.php"? RewriteRule !\.(gif|jpg|png|css|js|php|ico|xml)$ /index.php ...

how would i design a db to contain a set of url regexes (python) that could be matched against an incoming url

Say I have the following set of urls in a db url data ^(.*)google.com/search foobar ^(.*)google.com/alerts barfoo ^(.*)blah.com/foo/(.*) foofoo ... 100's more Given any url in the wild, I would like to check to see if that url belongs to an existing set of urls and get the corresponding data field. My questi...

Replace certain pattern in a long string in MS SQL using T-SQL

Hi all, I have a table in my MS SQL database where it has some incomplete data in a field. This field in question is a varchar field and has about 1000 characters in the field. This string consists of segmentations of words in the format of a forward slash followed by the segment and then ends with a forward slash (i.e. /p/). Each of...

Regex to match a URL pattern for a htaccess file

I'm really struggling with this regex. We're launching a new version of our "groups" feature, but need to support all the old groups at the same URL. Luckily, these two features have different url patterns, so this should be easy? Right? Old: domain.com/group/$groupname New: domain.com/group/$groupid/$groupname The current regex ...

Canada postal code validation

Hi, I need to validate Canada postal code (for example:M4B 1C7) using C# regular expressions. Please help. Thanks. ...

RegExKitLite Expression Question

I'm having trouble coming up with an RegExKitLite expression that will match. I'm parsing a string and I want it to grab everything till it comes upon the first occurrence of a colon What would be the expression in RegExKitLite to do that? Thanks! ...

Regex and Excel Cells

There is a .NET opensource library called NPOI that allows you to manipulate Excel files. Unfortunately, their ShiftRows function does not adjust any cell references in formulas. Therefore, I need to create a regex pattern to update them. Take for example a cell containing the following formula: =(B7/C9) * (A10-B4) I would like to b...

Is there a tool that enables me to insert one line of code into all functions and methods in a C++-source file?

It should turn this int Yada (int yada) { return yada; } into this int Yada (int yada) { SOME_HEIDEGGER_QUOTE; return yada; } but for all (or at least a big bunch of) syntactically legal C/C++ - function and method constructs. Maybe you've heard of some Perl library that will allow me to perform these kinds of operations...

Intelligencia.UrlRewriter rule help

Hi, i have got below rule that works fine with standart domain names like .net.com,.mobi but if domain name has 2 parts like co.uk it doesn't work. How can i adjust it so it would work with .net,.com and .co.uk at same time? <if header="HTTP_HOST" match="^(?:www\.)?([^.]+)\.([^.]+)\.([^.]+)$"> <set property="subdomain" value=...

Does /abcd^$/i match anything in Perl?

Perl is one of the things I never quite had the justification to get into. Unfortunately, I've got a very specific (looks like a bug to me) bit of Perl code, and I need to define it's operation provably. This code is written and in production already, I wish to have it removed. I believe it's impossible to successfully match, but it'...

Regular Expression to collect everything after the last /

I'm new at regular expressions and wonder how to phrase one that collects everything after the last /. I'm extracting an ID used by googles gdata. my example string is http://spreadsheets.google.com/feeds/spreadsheets/p1f3JYcCu_cb0i0JYuCu123 Where the ID is p1f3JYcCu_cb0i0JYuCu123 Oh and I'm using PHP. ...

php regex for html

hey guys, I'm trying to make a regex for taking some data out of a table. the code i've got now is: <table> <tr> <td>quote1</td> <td>have you trying it off and on again ?</td> </tr> <tr> <td>quote65</td> <td>You wouldn't steal a helmet of a policeman</td> </tr> </table> This I want to replace by: quot...

Regular expression for Indian mobile phone numbers?

I'm looking for a regular expression that will match text given the following requirements: contains only 10 digits (only numbers) starts with 9. These examples should match: 9999999999 9876543210 These examples should not match: 999999999 1234567890 8912456789 qwe3456&ert It is basically for Indian mobile numbers. Please pr...

Is this a bug in dotnet Regex-Parser?

I just wrote a regexp to do a basic syntax checking if a string is a valid math formular. I just define a group of valid chars and check if a string matches (I shortend the regex a little: private static readonly String validFormuar = @"^[\d\+-\*\/]+$"; private static bool IsValidFormular(String value) { return Rege...

Regex for alphanumeric and the + character

Hi, I need a regex that allows only alphanumeric plus the + and - character. Right now I am using: [^\w-] ...

Creating a regex to check for a strong password

Hi, Say I have a regex that checks for alphanumeric. I now want to create another regex that checks for at least 1 number in the password. And I want to check if it has at least 1 non-alphanumeric character (somethign other than a letter or number). Should I just call each one seperatley, and if one fails return false or is there a wa...