473,394 Members | 1,180 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,394 software developers and data experts.

Japanese regular expressions!

tim
Hi there!

I am in Japan right now fiddeling with an JP to AD date change program, for
this I have constructed one block where the date is inputted, and which
decides wether it will go to the AD to JP, or JP to AD change block.. Like
so:

public string ChangeDate(string tmpDate)
{
Match
m=Regex.Match(tmpDate,"^(19[0-9][0-9]|20[0-9][0-9])[/.]([0]{0,1}[1-9]|1[012])[/.]([0]{0,1}[1-9]|[12][0-9]|3[01])$");

Match
o=Regex.Match(tmpDate,"^\\Id*[1-9][0-9]\\Id([0]{0,1}[1-9]|1[012])\\Id([0]{0,1}[1-9]|[12][0-9]|3[01])\\Id$");
string retValue = "";

if (m.Success==true) //If tmpDate is AD Date.
{
retValue = this.GetJpDate(Convert.ToDateTime(tmpDate));
if (retValue != null)
return retValue;}
else if (o.Success==true) //If tmpDate is JP Date.
{
retValue = this.GetAdDate(tmpDate).ToString("yyyy/MM/dd");
if (retValue != null)
return retValue;}
else
{
throw(new Exception());}
return retValue;
}

A Japanese date is constructed like so: 平成12年12月12日, and here is the
problem, I can not "Match o" to work (return true), even if I match to a
single Kanji character, I cannot get a match! How do I match Kanji
characters, I tried every ms solution I could find.

Can anybody help me with this dilemma?

Tim

Nov 16 '05 #1
4 6105
Christ!
Japanese is complicated enough! So are regular expressions.

But *japanaese regular expressions* !

Rather you than me!
"tim" wrote:
Hi there!

I am in Japan right now fiddeling with an JP to AD date change program, for
this I have constructed one block where the date is inputted, and which
decides wether it will go to the AD to JP, or JP to AD change block.. Like
so:

public string ChangeDate(string tmpDate)
{
Match
m=Regex.Match(tmpDate,"^(19[0-9][0-9]|20[0-9][0-9])[/.]([0]{0,1}[1-9]|1[012])[/.]([0]{0,1}[1-9]|[12][0-9]|3[01])$");

Match
o=Regex.Match(tmpDate,"^\\Id*[1-9][0-9]\\Id([0]{0,1}[1-9]|1[012])\\Id([0]{0,1}[1-9]|[12][0-9]|3[01])\\Id$");
string retValue = "";

if (m.Success==true) //If tmpDate is AD Date.
{
retValue = this.GetJpDate(Convert.ToDateTime(tmpDate));
if (retValue != null)
return retValue;}
else if (o.Success==true) //If tmpDate is JP Date.
{
retValue = this.GetAdDate(tmpDate).ToString("yyyy/MM/dd");
if (retValue != null)
return retValue;}
else
{
throw(new Exception());}
return retValue;
}

A Japanese date is constructed like so: 121212, and here is the
problem, I can not "Match o" to work (return true), even if I match to a
single Kanji character, I cannot get a match! How do I match Kanji
characters, I tried every ms solution I could find.

Can anybody help me with this dilemma?

Tim

Nov 16 '05 #2
Have you tried matching for a unicode control code?
Like: Regex.Match(tmpDate, @"\1234") - which should match for the unicode
character with the code 1234. I always thought that would work for any kind
of character.

Niki

"tim" <ti*@chiikikagaku.co.jp> wrote in
news:OQ**************@TK2MSFTNGP15.phx.gbl...
Hi there!

I am in Japan right now fiddeling with an JP to AD date change program,
for this I have constructed one block where the date is inputted, and
which decides wether it will go to the AD to JP, or JP to AD change
block.. Like so:

public string ChangeDate(string tmpDate)
{
Match
m=Regex.Match(tmpDate,"^(19[0-9][0-9]|20[0-9][0-9])[/.]([0]{0,1}[1-9]|1[012])[/.]([0]{0,1}[1-9]|[12][0-9]|3[01])$");

Match
o=Regex.Match(tmpDate,"^\\Id*[1-9][0-9]\\Id([0]{0,1}[1-9]|1[012])\\Id([0]{0,1}[1-9]|[12][0-9]|3[01])\\Id$");
string retValue = "";

if (m.Success==true) //If tmpDate is AD Date.
{
retValue = this.GetJpDate(Convert.ToDateTime(tmpDate));
if (retValue != null)
return retValue;}
else if (o.Success==true) //If tmpDate is JP Date.
{
retValue = this.GetAdDate(tmpDate).ToString("yyyy/MM/dd");
if (retValue != null)
return retValue;}
else
{
throw(new Exception());}
return retValue;
}

A Japanese date is constructed like so: 平成12年12月12日, and here is the
problem, I can not "Match o" to work (return true), even if I match to a
single Kanji character, I cannot get a match! How do I match Kanji
characters, I tried every ms solution I could find.

Can anybody help me with this dilemma?

Tim

Nov 16 '05 #3
tim
Hi Niki!

Thanx, yes I have, the problem is that will only work untill the present
Japanese Era, when a new one begins, (new Emporer takes over) the name of
the Era changes and the program becomes obsolite, so I need an expression
that will represent all JP chars. Any Ideas??

Tim
"Niki Estner" <ni*********@cube.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Have you tried matching for a unicode control code?
Like: Regex.Match(tmpDate, @"\1234") - which should match for the unicode
character with the code 1234. I always thought that would work for any
kind of character.

Niki

"tim" <ti*@chiikikagaku.co.jp> wrote in
news:OQ**************@TK2MSFTNGP15.phx.gbl...
Hi there!

I am in Japan right now fiddeling with an JP to AD date change program,
for this I have constructed one block where the date is inputted, and
which decides wether it will go to the AD to JP, or JP to AD change
block.. Like so:

public string ChangeDate(string tmpDate)
{
Match
m=Regex.Match(tmpDate,"^(19[0-9][0-9]|20[0-9][0-9])[/.]([0]{0,1}[1-9]|1[012])[/.]([0]{0,1}[1-9]|[12][0-9]|3[01])$");

Match
o=Regex.Match(tmpDate,"^\\Id*[1-9][0-9]\\Id([0]{0,1}[1-9]|1[012])\\Id([0]{0,1}[1-9]|[12][0-9]|3[01])\\Id$");
string retValue = "";

if (m.Success==true) //If tmpDate is AD Date.
{
retValue = this.GetJpDate(Convert.ToDateTime(tmpDate));
if (retValue != null)
return retValue;}
else if (o.Success==true) //If tmpDate is JP Date.
{
retValue = this.GetAdDate(tmpDate).ToString("yyyy/MM/dd");
if (retValue != null)
return retValue;}
else
{
throw(new Exception());}
return retValue;
}

A Japanese date is constructed like so: 平成12年12月12日, and here is the
problem, I can not "Match o" to work (return true), even if I match to a
single Kanji character, I cannot get a match! How do I match Kanji
characters, I tried every ms solution I could find.

Can anybody help me with this dilemma?

Tim



Nov 16 '05 #4
"tim" <ti*@chiikikagaku.co.jp> wrote in
news:ev**************@TK2MSFTNGP09.phx.gbl...
Hi Niki!

Thanx, yes I have, the problem is that will only work untill the present
Japanese Era, when a new one begins, (new Emporer takes over) the name of
the Era changes and the program becomes obsolite, so I need an expression
that will represent all JP chars. Any Ideas??


Oh, I see. Interesting calendar. Can't you match for a character range then
(like [\1234-\2345])? What kind of characters are these, i.e. do they have a
common unicode character class? Do you know how many characters to expect,
could you maybe just use something like [^0-9]{3}?

Niki
Nov 16 '05 #5

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

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
1
by: Sven Hanefeld | last post by:
Hi, who is able to help. I want to translate my whole website into japanese language. www.nord-com.net/hanefeld What do I have to do except finding a japanese guy for the translation. Do I...
2
by: Sehboo | last post by:
Hi, I have several regular expressions that I need to run against documents. Is it possible to combine several expressions in one expression in Regex object. So that it is faster, or will I...
4
by: Egyd Csaba | last post by:
Hi All, I'd like to "compress" the following two filter expressions into one - assuming that it makes sense regarding query execution performance. .... where (adate LIKE "2004.01.10 __:30" or...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
1
by: Allan Ebdrup | last post by:
I have a dynamic list of regular expressions, the expressions don't change very often but they can change. And I have a single string that I want to match the regular expressions against and find...
13
by: Wiseman | last post by:
I'm kind of disappointed with the re regular expressions module. In particular, the lack of support for recursion ( (?R) or (?n) ) is a major drawback to me. There are so many great things that can...
4
by: kettle | last post by:
Hi, I am rather new to python, and am currently struggling with some encoding issues. I have some utf-8-encoded text which I need to encode as iso-2022-jp before sending it out to the world. I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.