regex

Parse Date from String in this format : dd/MM/yyyy [to dd/MM/yyyy]

Hi guys, I thinking what is the best way in Java to parse the String with this format dd/MM/yyyy [to dd/MM/yyyy]. The string with the [] are optional and dd stand for the 2 digit presentation of dates, MM is the 2 digit presentation of month and yyyy is the 4 digit presentation of year. Update Thanks guys for the fast response, howe...

Function to Make Pascal Case? (C#)

I need a function that will take a string and "pascal case" it. The only indicator that a new word starts is an underscore. Here are some example strings that need to be cleaned up: price_old => Should be PriceOld rank_old => Should be RankOld I started working on a function that makes the first character upper case: public string F...

how to find this with regex

Possible Duplicate: What is the best regular expression for validating email addresses? Hi How can I find emails with regex ? "[email protected]" "[email protected]" "[email protected]" "[email protected]" "[email protected]" Also how can I find this items : track0; (any track number); track50 (any track numb...

Find and replace for equations (regex?)

I'm converting some excel formulas to another system and need to do some fairly nifty search and replace magic. I presume Regex are the tools for the job in this case, but if anyone has any other ideas I'd like to hear them. I'm working on getting these formulas into something resembling SQL syntax. I also have to deal with algebraic sy...

How do you call a string that matches /^\w+$/?

Strings that match /^\w+$/ are quite common. For example many authentication systems use that pattern to validate usernames. I'm wondering if a term exists that identifies this kind of strings. I've been thinking of the term "alphanumeric" but is a string alphanumeric if it contains an underscore? ...

trim in javascript ? what this code is doing?

I was looking for a trim function in JavaScript which doesn't exist and some code on Goggling suggests that use: function trimStr(str) { return str.replace(/^\s+|\s+$/g, ''); } I want to know how str.replace(/^\s+|\s+$/g, '') works. I understand that this is some form of regular expression but dont know what it is doing. ...

How to get the last part of a string?

Given this string: http://s.opencalais.com/1/pred/BusinessRelationType I want to get the last part of it: "BusinessRelationType" I have been thinking about reversing the whole string then looking for the first "/", take everything to the left of that and reverse that. However, I'm hoping there is a better/more concise method. Thought...

Password validation Regular expression

I have a password validation like the following rules Should contains at most 15 chars and 8 chars at least Password should contain 2 numeral character There is no importance where to put the two numeral chars in start or end even if they anywhere in the password ...

how to extract a single digit in a number using regexp

set phoneNumber 1234567890 this number single digit, i want divide this number into 123 456 7890 by using regexp. without using split function is it possible? ...

c#.net Error Looping throgh an Enumerator

I have created a .bat file that displays a servers terminal Service SessionID and Username. Im Displaying the Information in a datagrid Here is the output of the .bat file: C:\Documents and Settings\adcock>qwinsta /server:ilsap01 SESSIONNAME USERNAME ID STATE TYPE DEVICE console ...

Get second part of a string using RegEx

Hi there, I have string like this "first#second", and I wonder how to get "second" part without "#" symbol as result of RegEx, not as match capture using brackets upd: I forgot to add one more special char at the end of string, real string is "first#second*" ...

Trying to hide a part of the url with mod_rewrite

Hi, I'm attempting to hide a part of an url from the address, because it's useless mouse coordinates sent due to input type="image" The URL is: www.example.com/search.html?mode=fulltext&query=HelloWorld&ssubmit.x=0&ssubmit.y=0 I want to hide the ssubmit.x and ssubmit.y part. I tried adding the following rule to .htaccess, but withou...

Wrap Field in a Line with Variable Number of Separators

Hello all, I have a file that uses the pipe character as a separator since I assumed that most of my clients wouldn't use the pipe character in their data. Apparently I was wrong, but I compensated for this by specifying that any fields using the pipe character need to be wrapped in double quotes. Unfortunately, they haven't done this, ...

Getting Query Parameter from a URL which inturn has some URL with Query parameters

Hello all I've the following URL http://somesite/somepage.aspx I pass a query parameter value which has another URL with query parameters like this. http://somesite/somepage.aspx?pageURL=http://someothersite/someotherpage.aspx?param1=value&source=http://anotheronesite/anotherpage I need to get the pageURL value as the one in th...

Regex HTTP header parsing

I'm trying to use Regex to get a bit if HTTP header parsing done. I'd like to use groups to organize some of the information: Let's say I have this: Content-Disposition: form-data; name="item1" I'd like the result of my regex to create two groups: contentdisposition : form-data name : item1 I've tried several methods, but I can't s...

Regex not matching repeated letters

myString = "THIS THING CAN KISS MY BUTT. HERE ARE MORE SSS"; myNewString = reReplace(myString, "[^0-9|^S{2}]", "|", "All"); myNewString is "|||S||||||||||||SS||||||||||||||||||||||||SSS" What I want is "||||||||||||||||SS|||||||||||||||||||||||||||" which is what I thought ^S{2} would do (exclude exactly 2 S). Why is it matching any ...

Extracting tokens where some are optional

I need to parse out time tokens from a string where the tokens are optional. Samples given: tt-5d10h tt-5d10h30m tt-5d30m tt-10h30m tt-5d tt-10h tt-30m How can I, in Python, parse this out preferably as the set (days, hours, minutes)? ...

Ruby 1.9 Regex Lookbehind Assertion & Anchors

Ruby 1.9 regex supports lookbehind assertion but I seem to have difficulty when passing anchors in the pattern. When anchors are passed in the lookahead assertion it runs just fine. "well substring! "[/(?<=^|\A|\s|\b)substring!(?=$|\Z|\s|\b)/] #=> RegexpError: invalid pattern in look-behind: /(?<=^|\A|\s|\b)substring(?=$|\Z|\s|\b)/ Do...

PHP 5.3 smart search and replace with regular expressions

OK, I need to scan many HTML / XHTML documents to see if a particular file has been embedded with SWFObject. If it's the case, I need to replace the call to something else. So far I have extracted the <script> contents where the calls can be made. Now I need to scan this string to check if the call is there and if it's there I need to r...

Replace string only once with php preg_replace

Hello, I need a replace string once function and believe preg_match might be my best bet. I was using this, but due to the dynamicness of use, sometimes this function behaves strangely: function str_replace_once($remove , $replace , $string) { $pos = strpos($string, $remove); if ($pos === false) { // Nothing found ...