473,320 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

String parser Using Regular Expression for Date format display using Locale Settings)

Hey Guys

I have a development environment, in which the whole SQL syntax is
stored in the Database.

So the syntax in the databse column could be

"where BirthDate = '12/31/2005' and ID = 345"

Note : The above string is stored and the dates are in US format. so
the dates are displayed in mm/dd/yyyy format, so when the user
retreives this record and shows it in the UI in textbox it would show
what is saved in the Databse - as the above string.

My requirement:-

If User's PC is in British Format (UK English) Locale settings then i
need to parse that string and display that in the UI.
so my expected result should show

"where BirthDate = '31/12/2005' and ID = 345"
Note: UI should show in UK format dd/mm/yyyy
So my idea is to parse the sting using regular expressions for date and
convert then to Client locale setting date format and while sending the
date back (where clause) to the databse then reconvert the string and
save it to the database in the US format.

The same goes for numbering system also. If the User PC is in italian
format then
ID = 345 should show ID = 3,45 (the way Italian format is shown).

I know how to deal with RegEx for password , email validations but not
to an extent of parsing and converting into a desired format.

Any suggestions or help would be really appreciated.

Thanks

Rahul

Jan 27 '06 #1
2 2804
I'm still pretty new to regex so this is going to be sloppy and
probably not the easiest way if it even works, but I would use
something like this after you match it:
string bdate = Regex.Match(val, "\d+/\d+/\d+").Value;
string month = Regex.Match(val, "^\d+/").Value;
string day = Regex.Match(val, "/\d+/")Value;
string year = Regex.Match(val, "/\d{4}").Value;

I'm not sure if this will work, but if it does as i intend it to,
you'll have a separate string for each part of the date, which you can
then order based on whichever d/t format you're working with. If this
doesn't work (I can't try it atm as i'm working on another project,
well, supposed to be at least) then you're going to have to make some
substrings, let me know, and if you still need help i'll take a better
stab at it.

Jan 27 '06 #2
Thanks KBUSer ,
I would try that and let you know for sure
Appreciate it

Rahul

Jan 30 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Babu Mannaravalappil | last post by:
Hi, I want to replace some words in my text files (actually transpose). For example, I have a whole lot of expressions (words) in my files as follows: TABLECUSTOMERS TABLEORDERS...
1
by: Laurence Neville | last post by:
This is regarding a change in the Short Date format under Hebrew Regional Settings, that has caused huge problems in our ASP web application. The change appears to have been introduced sometime...
7
by: hungrymind | last post by:
Hi all, I am developing some control (textbox based), to validate inputs to that control I am using regular expression, where pattern is generated dynamically. I need to identify what all...
11
by: lucky | last post by:
hi, i got file which contains "----------------" in a line. the line only contains this data as a saperation. using regular expression i want to i detify the line contains that data and replace...
1
by: Zorik | last post by:
I am building a form in asp.net 2.0 On one of the textboxes, I don't want that the user will use the space character. How do I disallow space using regular expression validator (or other...
3
by: mattmao | last post by:
Hello everyone. This question is regarding ISBN number checking. I've done it with my own algorithm, which is pretty bad in consideration about the total lines of code. Now I want to improve...
1
by: durga2005 | last post by:
hi I m validating a textbox using regular expression validator and these controls are placed inside the update panel the validation is not working inside update panel
4
by: Velhari | last post by:
Hi all, I wrote the following Javascript function used to execute the Javascript codes from the ajax response which contains both html & javascript. It works fine, if the javascript codes from...
4
by: lordelf007 | last post by:
Hiii all, I'm new in using Regular Expression in Java. For example, I have String s like this: String s = "Why John Smith and Alan Smith and Nick Gates are the same?" How can I get...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.