Hi,
I need a regular expression to validate a timestamp of the format, using Javascript:
YYYY/MM/DD HH:MI:SS
I tried cooking up a few, but seems my regex skills fail to cover something or other.
Please give me a reference or way to do it.
P.S. : I mention regex, only as a suggestion. Im using Javascript and welcome any alternative.
Hi,
Can anybody help me writting a regular expression to replace these characters with a empty string. Character list is given below.
public static char[] delimiters = { ' ', '\r', '\n', '?', '!', ';', '.', ',', '`', ':', '(', ')', '{', '}', '[', ']', '|', '\'', '\\', '~', '=', '@', '>', '<', '&', '%', '-', '/', '#' };
Thanks.
Subrat.
A frequent issue in code reviews is whether a numeric value should be hard-coded in the code or not. Does anyone know of a nice regular expression that can catch 'magic numbers' in code like:
int overDue = 30;
Money fee = new Money(5.25D);
without also getting a ton of false positives like for loop initialization code?
for (int i = 0; i < array.length; i++) {
}
can any one tell me regular expression for postalcode of Amsterdam, Netherlands for validation
EX. 1113 GJ
Postal code format according to Wikipedia (thanks to Pekka):
1011–1199 plus a literal suffix AA-ZZ,
e.g. 1012 PP
Sorry for the potentially dumb question but I am trying to pull together a regular expression that will allow:
A number with 1 or 2 numbers before a decimal point, and 0-6 numbers after the decimal point. However I also need to allow the field to be blank if so required.
Valid Examples
0.952321
1.20394
12.12
25
Blank
Invalid Examples
123.45678
1.1234567
Please can anyone help?
I was performing a code review for a colleague and he had a regular expression that looked like this:
if ($value =~ /^\d\d\d\d$/) {
#do stuff
}
I told him he should change it to:
if ($value =~ /^\d{4}$/) {
#do stuff
}
To which he replied that he preferred the first for readability (I find the second more readable, but that's a religious debate I'll save for another day).
My question: is there an actual benefit to one over the other?
Related to my previous question, I have a string on the following format:
this {is} a [sample] string with [some] {special} words. [another one]
What is the regular expression to extract the words within either square or curly brackets, ie.
{is}
[sample]
[some]
{special}
[another one]
Note: In my use case, brackets cannot be nested. I would also like to keep the enclosing characters, so that I can tell the difference between them when processing the results.
I have texts like this one:
this is a text in [lang lang="en" ]english[/lang] or a text in [lang lang="en" ]spanish[/lang]
I need to substitute them for:
this is a text in <span lang="en">english </span> or a text in <span lang="es">spanish</span>
I need a regular expression, not a simple replace. The languages in the lang tag can be whatever.
I need to be able to download some file from a regular site using my proxy server,
I already try this:
System.Net.WebClient client = new System.Net.WebClient();
client.Proxy = new WebProxy(ip, port);
client.DownloadFile(url);
but it's not works at all, I don't know what I missed,(without a proxy it works)
thanks,
Dani.
If you have a fair number of regular expressions used by both client (javascript) and server side code (C#, vb.net) and want to store them in one place to avoid duplication, where do you store them?
I could use registerscript and write out the regex as strings, but just wondering if there is something more elegant.
I receive Date and time from CSV file
The received Date format is YYYMMDD (string) (there is no ":" ,"-","/" to
separate Year month and date).
The received time format is HH:MM (24 Hour clock).
I have to validate both so that (example) (i) 000011990 could be invalidated for date (ii) 77:90 could be
invalidated for time.
The question is ,
Regular expression is the right candidate for do so (or) is there any other way to achieve
it?
Are there any known regular expressions out there to validate credit card track 1 and track 2 data?
EDIT:
Track 1 and Track 2 are the data tracks that are read from credit cards. See the Financial Cards section at http://en.wikipedia.org/wiki/Magnetic_stripe_card
I have a HTML page and I want to fetch the result between two tags <b> and <BR>
<b>Defendants Name:</b>Donahue, Leah A <BR>
What is the regular expression to fetch the words between these two tags
Hello,
I would like a regular expression in this format. It Must match one of the following formats:
* (###)###-####
* ###-###-####
* ###.###.####
* ##########
Strip all whitespace. Make sure it's a valid phone number, then (if necessary) translate it to the first format listed above.
I have text that looks like:
My name is (Richard) and I cannot do
[whatever (Jack) can't do] and
(Robert) is the same way [unlike
(Betty)] thanks (Jill)
The goal is to search using a regular expression to find all parenthesized names that occur anywhere in the text BUT in-between any brackets.
So in the text above, the result I am looking for is:
Richard
Robert
Jill
Dear Masters! Is it possible to ensure, that only characters with codes between 0 and 255 will be accepted by regular expression, but all with the codes up to 256 not? Thank you!
I would like to turn this query to regular inline sql without using stored procedures
declare @nod hierarchyid
select @nod = DepartmentHierarchyNode
from Organisation
where DepartmentHierarchyNode = 0x6BDA
select *
from Organisation
where @nod.IsDescendantOf(DepartmentHierarchyNode) = 1
Is there a way to do it?
I am looking for a regular expression (or other method if there is such a thing) for detecting bounce email messages. So far I have been going through our unattended mail box and adding strings that I find into a regex. I figured someone would have something that is already complete rather than me re-inventing the wheel.
Here is an example of what I have so far:
/reason: 550|permanent fatal errors|Error 550|Action: Failed|Mailbox does not exist|Delivery to the following recipients failed/i
I am trying to fix a regular expression i have been using in php it finds all find filenames within a sentence / paragraph. The file names always look like this: /this-a-valid-page.php
From help i have received on SOF my old pattern was modified to this which avoids full urls which is the issue i was having, but this pattern only finds one occurance at the begging of a string, nothing inside the string.
/^\/(.*?).php/
I have a live example here: http://vzio.com/upload/reg_pattern.php
Hey everybody,
I am a novice TCL programmer.Here I go My 1st post with stackoverflow forum. I would like to write a regular expression that matches any & only the strings starts with character A and ends with B. Whatever the characters coming inbetween should be displayed. For instance AXIOMB as an input from the user which starts with A & end with character B. Here is my try regexp { (^A([C-Z]+)B$)} Thank you
Hello all
I got this question which asks me to figure out why is it foolish to write a regular expression for the language that consists of strings of 0's and 1's that are palindromes( they read the same backwards and forwards).
part 2 of the question says using any formal mechanism of your choice, show how it is possible to express the language that consists of strings of 0's and 1's that are palindromes?
hi everyone. I can't seem to make my regular expression work.
I'd like to have some alpha text, no numbers, an underscore and then some more aplha text.
for example: blah_blah
I have an non-working example here
^[a-z][_][a-z]$
Thanks in advance people.
EDIT: I applogize, I'd like to enforce the use of all lower case.
I always get confused using regular expressions. Can anyone please suggest me a tutorial?
I need help with checking for a string which,
cannot contain any wild characters except colon, comma, full stop.
It will be better to replace these if found.
Any help?
Thanks.
Hello All,
I would like to use regular expression to extract only @patrick @michelle from the following sentence:
@patrick @michelle we having diner @home tonight do you want to join?
Note: @home should not be include in the result because, it is not at beginning of the sentence nor is followed by another @name.
Any solution, tip, comments will be really appreciated.