ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¼Æ¦r»P¼Æ¦r¤¤¦pªG¦³ªÅ®æ ­n¦p¦ó¨ú¥N©Î§R°£©O?

[µo°Ý] ¼Æ¦r»P¼Æ¦r¤¤¦pªG¦³ªÅ®æ ­n¦p¦ó¨ú¥N©Î§R°£©O?

·Q½Ð°Ý¦U¦ì¤j¤j
EXCEL¤¤ ¼Æ¦r»P¼Æ¦r¤¤¦pªG¦³ªÅ®æ ­n¦p¦ó¨ú¥N©Î§R°£©O?

1.µLªkª½±µ¨Ï¥ÎªÅ®æ( )¨ú¥N ¦]¬°·|¦³¤@¨Ç¥X²{ªÅ®æ¬O¬°¤À¬q¥X¼Æ¦rªº¼Æ­È

2.µLªk¨Ï¥Î(? ?)¨ú¥N¦¨(??) ¦]¬°?¬O¨â­Ó¦ì¼Æªº¨ú¥N¤èªk ¼vÅT
  ¦P¤W?ªº¨ú¥N±¡ªp (? )©Î( ?)¤]¤£¥i¥H¨Ï¥Î

3.¤]¦³·Q¹L¥Î¤E¤Q¤E¦¸ªº¨ú¥N¤èªk (1 1) ¨ú¥N¦¨(11) ¤]¬O«á¬q¼Æ­ÈµLªk¨Ï¥Î


µo¥Í³o¼Ëªº±¡ªp
ªÅ®æ¥u·|¥X²{¦b¼Æ¦rªº­Ë¼Æ²Ä¤G­Ó¦ì¸m ¨Ò¦p 1,00 0(¥¿½T¬°1,000)
¦ý"¼Æ­È"¤§¶¡¤]¬O·|¦³ªÅ®æªº¦s¦b ¨Ò¦p 1,000 5 1,000,000(¼Æ­È°Ï¬q¥i¯à¦³«Ü¦h)
(¨C¬q¼Æ­È¥i¯à¦³­Ó¦ì¼Æ1 ¦Ê¦ì¼Æ100  ¤d¦ì¼Æ1,000  ¸U¦ì¼Æ10,000 §ó¦h³£·|¥X²{)

¦p¦³VBAªº¤è¦¡¥i¥H³B²z ¬O³Ì¦n  

¦p¦³ªí¹F¤£²M·¡ ²`·P©êºp
Åwªï¤j¤jªº«ü±Ð   ¥ý·PÁ  ¦A·PÁÂ

¥þ³¡½d¥»ÀÉ®× 20160828¼Æ¦r¤¤¶¡ªÅ®æ°ÝÃD.rar (503.93 KB)

20160828¼Æ¦r¤¤¶¡ªÅ®æ°ÝÃD.rar (503.93 KB)

lo

¦^´_ 11# ¤p«L«È
³o­Ó­n¸ÑÄÀ¯uªº¤£¦n¸ÑÄÀ...
§Ú¬O·|³o¼Ë§ì°Õ¡A§A°Ñ¦Ò¬Ý¬Ý:
  1. Sub Test()
  2.     Dim oReg: Set oReg = CreateObject("vbscript.regexp")
  3.     Dim x, oMatch
  4.     Const EX1 = "1111 22222 3333¦~ 44444¦~ abc5555 abc6666¦~ abc77777 abc88888¦~"
  5.     With oReg
  6.         .Pattern = "(?:\b|\D)(\d{4})(?=¦~|\b)"
  7.         .Global = True
  8.         Set oMatch = .Execute(EX1)
  9.         For Each x In oMatch
  10.             Debug.Print "x=" & x, "x.submatches(0)=" & x.submatches(0)
  11.         Next
  12.     End With
  13. End Sub
½Æ»s¥N½X
¿é¥X·|¬O³o¼Ë¡A§A¦n¦nÅé·|¤@¤U
  1. x=1111     x.submatches(0)=1111
  2. x= 3333     x.submatches(0)=3333
  3. x=c5555    x.submatches(0)=5555
  4. x=c6666    x.submatches(0)=6666
½Æ»s¥N½X
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 11# ¤p«L«È
¤£ª¾¹D±zªº­ì©l¸ê®Æ¬O¤°»ò¼Ë¤l¡A¦pªG³o¨Ç¦r¦ê¤£·|¥X²{¦b¥y­º¸ò¥y§À¡A.test¨ºÃä´N¤£¥Î§ï
  1. Function IsYear (ByRef Target As String) As Boolean
  2.     Dim x, oRegexp As Object: Set oRegexp = CreateObject("vbscript.regexp")
  3.     With oRegexp
  4.         .Pattern = "\D(\d{4}¦~?)\D"
  5.         IsYear = .test("-" & Target & "-")
  6.     End With
  7. End Function
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ ­ã´£³¡ªL ©ó 2016-9-13 15:01 ½s¿è

¥¿«h¯uªº¤£®e©ö¡I¡I¡I

¸Õ¸Õ¤½¦¡¦p¦ó¡G
=SUM(--TEXT(1&RIGHT(LEFT(A1,FIND("¦~",A1&"¦~")-1),{4,5}),"[<11901]-9;[>12099]-9;1;!0"))>0

­­©w 1901~2099 ¦~¤§¶¡¬°¦³®Ä¦~¡A
02015¦~¡@Áö¬°¢±¢¯¢°¢´¦~¡A¦ý¦]§t¢´­Ó¼Æ¦r¡A§P¬°µL®Ä¡A
¤£¹L¡Aabcd2015ppuy ³o­Ó¤£§t"¦~"¦r¡A¢±¢¯¢°¢´´NµLªk¥Î³o¤½¦¡§PÂ_¡A
abcd2015¦~ppuy¡@´N¢Ý¢Ù¡I

TOP

¦^´_  ¤p«L«È
^ = ¤Ç°t¦r¦ê¶}ÀY
\d{1,2} = ¬O«ü«e­±ªº \d¥X²{¤@¦¸¨ì¨â¦¸
        ¥t¥~±`¥Î²¤Æ¼gªk
        \d? = \d ...
stillfish00 µoªí©ó 2016-9-2 11:17



    ÁÂÁ§A¡A§Ú¤w°µ¹L´ú¸Õ¡A¦n¹³¦¨¥\¤F¡C
§Ú¤]¨Ì¼Ë¸Õ¼g¤F¤@­ÓÀˬd¦r¦ê¤¤¦³¨S¦³¦~¥÷ªºfunction
True :
1) ¦p¦³¡u¦~¡v¦r®É¡A«e­±¦³4­Ó¼Æ¦r
2) ¦p¨S¦³¡u¦~¡v¦r¡A«e­±¦³4­Ó¼Æ¦r
  1. Function IsYear (ByRef Target As String) As Boolean
  2.     Dim x, oRegexp As Object: Set oRegexp = CreateObject("vbscript.regexp")
  3.     With oRegexp
  4.         .Pattern ="[0-9]{4}[¦~]?(?![0-9])"
  5.         IsYear = .test(Target)
  6.     End With
  7. End Function
½Æ»s¥N½X
°µ¤F´ú¸Õ¡A¦n¹³®ÄªG¤£¤Ó¦n¡C
1234
12345
1234¦~
12345¦~
abc1234
abc1234¦~
abc12345
abc12345¦~

³o8²Õ¤]¬OTRUE¡A¦ý§Ú¥u§Æ±æ²Ä1¡B3¡B5¡B6²Õ¬OTRUE¡C¥Î¤F{4}¤]µLªk­­¨î¼Æ¦r¦r¦ê¥u¯à¬O4­Ó¡C
§Ú¤w¸g¥[¤Fnegative lookahead (?![0-9]) ¡A­­¨î¼Æ¦r¦r¦ê«á¤£¥i¦A¸ò¼Æ¦r¡A¦ýVBA¦n¹³¤£¤ä´©negative lookbehind¡AµLªk­­¨î¼Æ¦r¦r¦êªº¶}©l¤£¬O¼Æ¦r.....

TOP

¦^´_ 9# ¤p«L«È
^ = ¤Ç°t¦r¦ê¶}ÀY
\d{1,2} = ¬O«ü«e­±ªº \d¥X²{¤@¦¸¨ì¨â¦¸
        ¥t¥~±`¥Î²¤Æ¼gªk
        \d? = \d{0,1}
        \d+ = \d{1,}
        \d* = \d{0,}

[)\.] = ¬O¡u)¡v©Î¬O¡u.¡v³æ¤@¦r¤¸
        ¦pªG³o­Ó¦r¤¸ªº¤Ç°t¥i¦³¥iµL(¥X²{0¦¸¨ì1¦¸)¡A
        ¥i¥H¦b«á­±¥[°Ý¸¹
        [)\.]? = [)\.]{0,1}

³Ì«áªº .*
    .¤~¬Oªí¥Ü¥ô·N¦r¤¸  *ªí¥Ü¥X²{0¦¸¨ì¥ô·N¦h¦¸
    §Ú¨S¦³¯S§O¥h¤Ç°t¤¤¤å¦r¡A­n¤Ç°t¥¿Å餤¤åÀ³¸Ó¬O[\u4e00-\u90a5]

­Y¨Ì§Aªº±ø¥ó:
1) ¥H¤@­Ó©Î¨â­Ó¼Æ¦r§@¶}©l¡A¥]§t¤¤°ê¼Æ¦r¤@¤G¤T¥|¤­¤»¤C¤K¤E¤Q
2) ¼Æ¦r«á·|¥H¡u)¡v¡B¡u.¡v§@¤À¹j(¦³®É­Ô¬O¨S¦³)
3) ¤§«á¥]§t¤F¤@ªÅ®æ (¥²©w¤@ªÅ®æ)
4) ¤§«á±µ¥¿Å餤¤å (°²³]¦Ü¤Ö¤@¤¤¤å¦r)

¥i¼g¦¨
^[0-9¤@¤G¤T¥|¤­¤»¤C¤K¤E¤Q]{1,2}[)\.]?\s[\u4e00-\u90a5]+"
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¥»©«³Ì«á¥Ñ ¤p«L«È ©ó 2016-9-2 10:37 ½s¿è
¦^´_  ¤p«L«È
°Ñ¦Ò§a1) ³¯¤j¤å   True
32. ª`·N¨Æ¶µ True
123) ¨ä¥L   False
stillfish00 µoªí©ó 2016-9-1 16:13


§Úµo²{¨ìªº¤å¦r¼Ò¦¡¬O¡G
1) ¥H¤@­Ó©Î¨â­Ó¼Æ¦r§@¶}©l
2) ¼Æ¦r«á·|¥H¡u)¡v¡B¡u.¡v§@¤À¹j(¦³®É­Ô¬O¨S¦³)
3) ¤§«á¥]§t¤F¤@ªÅ®æ
4) ¤p¬q¸¨ªº¼ÐÃD(¥¿Å餤¤å)
  1.     "^\d{1,2}[)\.]\s.*"
½Æ»s¥N½X
\d =¼Æ¦r¡A¦pªG­n¥]§t¤¤°ê¼Æ¦r¡A¬O¤£¬O[0-9¤@¤G¤T¥|¤­¤»¤C¤K¤E¤Q]
{1,2} = ­º¤@¦Ü¤G¦r
[)\.] = ¼Æ¦r«á¬O¡u)¡v¡B¡u.¡v¡A¤Ö¼Æ±¡ªp¬O¡G¡u12 ¤Ñ®ð±¡ªp¡v¡A¼Æ¦r«á¥u¦³¤@ªÅ®æµM«á¬O¼ÐÃD¡A¬O¤£¬O§ï¦¨
  1. [)\.\s]
½Æ»s¥N½X
¡A¦ý³o¼Ë·|©M«á­±ªº\s¬Û¨R¡A¦Ó¥Oµ{¦¡¥H¬°­n¦³¨âªÅ®æ
* = ¸U¥Î½X

¦pªG­n²Å¦X§Úªº­n¨D¡A¬O¤£¬O§ï¦¨
  1. ^[0-9¤@¤G¤T¥|¤­¤»¤C¤K¤E¤Q]{1,2}[)\.\s]\s.*"
½Æ»s¥N½X

TOP

¦^´_ 6# ­ã´£³¡ªL


    ¹ï¤£°_¡A§Ú²z¸Ñ¿ù¤F¡A§ÚÁÙ¥H¬°¬Oregular expression¡C
¦]¬°§Ú»Ý­n¦b¼Æ¸U½g¤å³¹¤¤§ä¥X¤p¬q¸¨ªº¶}ºÝ¡A¦Ó¤å³¹ªº®æ¦¡¨Ã¤£¬Û¦P¡A©Ò¥H§Ú»Ý­n¥H¸û¦³®Äªº¤èªk§ä¥X¤p¼ÐÃD¡AµM«á¥[¤W¼Æ¶µÅçÃÒ¥H½T»{³o¬O§Ú»Ý­nªº¬qÓ¨¡C
¼È®É§ÚÆ[¹î¤F¼Æ¦Ê½g¤å³¹«á¡A¼È®É§Úµo²{¨ìªº¼Ò¦¡¬O¡G
1) ¥H¤@­Ó©Î¨â­Ó¼Æ¦r§@¶}©l
2) ¼Æ¦r«á·|¥H¡u)¡v¡B¡u.¡v§@¤À¹j(¦³®É­Ô¬O¨S¦³)
3) ¤§«á¥]§t¤F¤@ªÅ®æ
4) ¤p¬q¸¨ªº¼ÐÃD(¥¿Å餤¤å)

¨ä¹ê¤W­±ªº¤w¸g¬O¨Ò¤l¡A¤£¹L¥i¯à¤Ó¤Ö¡A§Ú­nÂI®É¶¡¦A¾ã²z§a¡C

TOP

¦^´_ 5# ¤p«L«È
°Ñ¦Ò§a
  1. Sub Test()
  2.     Dim x, oRegexp As Object: Set oRegexp = CreateObject("vbscript.regexp")
  3.     With oRegexp
  4.         .Pattern = "^\d{1,2}[)\.]\s.*"
  5.         
  6.         For Each x In Array("1) ³¯¤j¤å", "32. ª`·N¨Æ¶µ", "123) ¨ä¥L")
  7.             Debug.Print x, .Test(x)
  8.         Next
  9.     End With
  10. End Sub
½Æ»s¥N½X
1) ³¯¤j¤å   True
32. ª`·N¨Æ¶µ True
123) ¨ä¥L   False
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 5# ¤p«L«È

4¼Ó¥Îªº¥u¬O«Ü´¶³qªº§PÂ_¦¡, »P¥¿«hµLÃö, ©|¥B§Ú¹ï¥¿«h¨ÃµL¬ã¨s!!!

¨ú¤å¦rªº°ÝÃD, ¶·¥ý¬Ý§¹¾ãªº¤å¦r, ¦Ó«D¤ù¬q, §_«h¤£ºÞ¥Î¥¿«h©Î¨ä¥¦¤èªk, ³£¥i¯à¥X¿ù!

³Ì¦nªþ¤W³Ì§¹¾ãªº¤º®e¤Î»Ý¨D, ¯à¼ÒÀÀµ²ªG§ó¦n!

TOP

        ÀR«ä¦Û¦b : ºÉ¦h¤Ö¥»¥÷¡A´N±o¦h¤Ö¥»¨Æ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD