timirish

timirish

  • NA
  • 3
  • 0

Japanese regular expressions!!

Nov 8 2004 8:27 PM
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 a 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. Does anybody know a solution? Thanx in advance! Kind regards, Tim

Answers (1)