Code for converting the amount into RMB capital in regular expression 1

Source: Internet
Author: User

Copy codeThe Code is as follows: public static string ConvertToChineseMoney (double money)
{
If (money <0)
Throw new ArgumentOutOfRangeException ("the parameter money cannot be a negative value! ");
String s = money. toString ("# L # E # D # C # K # E # D # C # J # E # D # C # I # E # D # C # H # E # D # C # G # E # D # C # F # E # D # C #. 0B0A ");
S = Regex. Replace (s ,@"((? <=-| ^) [^ 1-9] *) | ((? 'Z' 0) [0A-E] * (? = [1-9]) | (? '-Z '(? = [F-L \.] | $) | ((? 'B' [F-L]) (? 'Z' 0) [0A-L] * (? = [1-9]) | (? '-Z '(? = [\.] | $) "," $ {B }$ {z }");
Return Regex. replace (s ,". ", delegate (Match m) {return" negative element null 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3. value [0]-']. toString ();});
}

Call this method:Copy codeThe Code is as follows: Random r = new Random ();
For (int I = 0; I <10; I ++)
{
Double MB = r. Next ()/100.0;
Response. Write (m + "----" + ConvertToChineseMoney (m) + "<br/> ");
}

Running result:

5970370.36 ---- Wu yunqi pick up the points and points
6521548.6 ---- Lu Yi Wu Xi Si Xi Yuan Lu Jiao
12179380.35 ---- yi Cheng
15742735.47 ---- Yi Wu Yu, Xiao Si, Xiao Yu, Wu Yuan Si Jiao Min
9236554.09 ---- yuan
9706980.49 ---- just pick up the yuan and then pick up the yuan
11873034.16 ---- yi Yu Yi Qi Si Yuan Yi Jiao Lu fen
21141596.22 ---- just a few minutes, just a few minutes.
17040243.44 ---- yi si
5358585.54 ---- Wu yunqi Wu Yunxiao

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.