oracleµÄÕýÔò±í´ïʽ(regular expression)¼òµ¥½éÉÜ
Ä¿Ç°£¬ÕýÔò±í´ïʽÒѾÔںܶàÈí¼þÖеõ½¹ã·ºµÄÓ¦Ó㬰üÀ¨*nix£¨Linux, UnixµÈ£©£¬HPµÈ²Ù×÷ϵͳ£¬PHP£¬C#£¬JavaµÈ¿ª·¢»·¾³¡£
Oracle 10gÕýÔò±í´ïʽÌá¸ßÁËSQLÁé»îÐÔ¡£ÓÐЧµÄ½â¾öÁËÊý¾ÝÓÐЧÐÔ£¬ Öظ´´ÊµÄ±æÈÏ, Î޹صĿհ׼ì²â£¬»òÕß·Ö½â¶à¸öÕýÔò×é³É
µÄ×Ö·û´®µÈÎÊÌâ¡£
Oracle 10gÖ§³ÖÕýÔò±í´ïʽµÄËĸöк¯Êý·Ö±ðÊÇ£ºREGEXP_LIKE¡¢REGEXP_INSTR¡¢REGEXP_SUBSTR¡¢ºÍREGEXP_REPLACE¡£
ËüÃÇʹÓÃPOSIX ÕýÔò±í´ïʽ´úÌæÁËÀϵİٷֺţ¨%£©ºÍͨÅä·û£¨_£©×Ö·û¡£
ÌØÊâ×Ö·û£º
'^' Æ¥ÅäÊäÈë×Ö·û´®µÄ¿ªÊ¼Î»Öã¬ÔÚ·½À¨ºÅ±í´ïʽÖÐʹÓ㬴ËʱËü±íʾ²»½ÓÊܸÃ×Ö·û¼¯ºÏ¡£
'$' Æ¥ÅäÊäÈë×Ö·û´®µÄ½áβλÖá£Èç¹ûÉèÖÃÁË RegExp ¶ÔÏóµÄ Multiline ÊôÐÔ£¬Ôò $ ҲƥÅä 'n' »ò 'r'¡£
'.' Æ¥Åä³ý»»Ðзû nÖ®ÍâµÄÈκε¥×Ö·û¡£
'?' Æ¥ÅäÇ°ÃæµÄ×Ó±í´ïʽÁã´Î»òÒ»´Î¡£
'*' Æ¥ÅäÇ°ÃæµÄ×Ó±í´ïʽÁã´Î»ò¶à´Î¡£
'+' Æ¥ÅäÇ°ÃæµÄ×Ó±í´ïʽһ´Î»ò¶à´Î¡£
'( )' ±ê¼ÇÒ»¸ö×Ó±í´ïʽµÄ¿ªÊ¼ºÍ½áÊøλÖá£
'[]' ±ê¼ÇÒ»¸öÖÐÀ¨ºÅ±í´ïʽ¡£
'{m,n}' Ò»¸ö¾«È·µØ³öÏÖ´ÎÊý·¶Î§£¬m=<³öÏÖ´ÎÊý<=n£¬'{m}'±íʾ³öÏÖm´Î£¬'{m,}'±íʾÖÁÉÙ³öÏÖm´Î¡£
'|' Ö¸Ã÷Á½ÏîÖ®¼äµÄÒ»¸öÑ¡Ôñ¡£Àý×Ó'^([a-z]+|[0-9]+)$'±íʾËùÓÐСд×Öĸ»òÊý×Ö×éºÏ³ÉµÄ×Ö·û´®¡£
num Æ¥Åä num£¬ÆäÖÐ num ÊÇÒ»¸öÕýÕûÊý¡£¶ÔËù»ñÈ¡µÄÆ¥ÅäµÄÒýÓá£
ÕýÔò±í´ïʽµÄÒ»¸öºÜÓÐÓõÄÌصãÊÇ¿ÉÒÔ±£´æ×Ó±í´ïʽÒÔºóʹÓ㬠±»³ÆΪBackreferencing. ÔÊÐí¸´ÔÓµÄÌæ»»ÄÜÁ¦
Èçµ÷ÕûÒ»¸öģʽµ½ÐµÄλÖûòÕßָʾ±»´úÌæµÄ×Ö·û»òÕßµ¥´ÊµÄλÖÃ. ±»Æ¥ÅäµÄ×Ó±í´ïʽ´æ´¢ÔÚÁÙʱ»º³åÇøÖУ¬
»º³åÇø´Ó×óµ½ÓÒ±àºÅ, ͨ¹ýÊý×Ö·ûºÅ·ÃÎÊ¡£ ÏÂÃæµÄÀý×ÓÁгöÁË°ÑÃû×Ö aa bb cc ±ä³É
cc, bb, aa.
Select REGEXP_REPLACE('aa bb cc','(.*) (.*) (.*)', '3, 2, 1') from dual£»
REGEXP_REPLACE('ELLENHILDISMIT
cc, bb, aa
'' תÒå·û¡£
×Ö·û´Ø£º
[[:alpha:]] ÈκÎ×Öĸ¡£
[[:digit:]] ÈκÎÊý×Ö¡£
[[:alnum:]] ÈκÎ×ÖĸºÍÊý×Ö¡£
[[:space:]] Èκΰ××Ö·û¡£
[[:upper:]] Èκδóд×Öĸ¡£
[[:lower:]] ÈκÎСд×Öĸ¡£
[[:punct:]] Èκαêµã·ûºÅ¡£
[[:xdigit:]] ÈκÎ16½øÖƵÄÊý×Ö£¬Ï൱ÓÚ[0-9a-fA-F]¡£
¸÷ÖÖ²Ù×÷·ûµÄÔËËãÓÅÏȼ¶
תÒå·û
(), (?:), (?=), [] Ô²À¨ºÅºÍ·½À¨ºÅ
*, +, ?, {n}, {n,}, {n,m} ÏÞ¶¨·û
^, $, anymetacharacter λÖúÍ˳Ðò
| “»ò”²Ù×÷
--²âÊÔÊý¾Ý
create table test(mc varchar2(6
Ïà¹ØÎĵµ£º
ËäȻѧϰJavaºÜ¾ÃÁË£¬×Ô¼ºÒ²Á¬½Ó¹ýһЩÊý¾Ý¿â£¬±ÈÈçmysqlÖ®ÀàµÄ£¬Èç½ñÄØ£¬Ò²Ñ§Ï°ÁËÒ»¶Îʱ¼äµÄOracle£¬È»¶øÄØ£¬½ñÌìÊÇÎÒµÚÒ»´ÎÁ¬½ÓOracle£¬ºÙºÙ£¬Ó¦¸Ã»¹²»ËãÌ«³Ù°É¡£
½ñÌìÄØ£¬Óе㱿׾£¬´ó¼ÒĪЦ£¡
ÎÒÕâÊÇÒ»¸ö²éѯÀý×Ó
Ê×ÏÈ£¬Ô ......
½éÉÜto_char(Êý×Ö, ‘¸ñʽ’)£¬±È½Ï³£Óõĸñʽ
9 ±íʾÓÐЧλÊý
0 ÓÃ0²¹×ãλÊý
B Óÿոñ²¹×ãλÊý
ÔÊýµÄλÖÃÓÐʵ¼ÊÊý×ÖռλµÄʱºò£¬0ºÍ9µÄЧ¹ûÊÇÒ»ÑùµÄ¡£
0ºÍ9µÄÇø±ðÔÚÓÚ¸ñʽÖеÄÄÇһλÖÃʵ¼ÊÊý×ÖûÓÐվλµÄÇé¿öÏ¡£
select to_char(0.45,'0.99'); ½á¹ûÊÇ0.45
select ......
ÓÃtg4mssqlÁ´½Óoracle.
¹ý³Ì²»ÔÚÃèÊö£¬googleºÜ¶à¡£
ÎÊÌ⣺
1¡¢mssql expressµÄʱºò£¬Ê§°Ü
½«serverÓÃתÒå×Ö·ûд³ö£¬³É¹¦¡£
HS_FDS_CONNECT_INFO="SERVER=SHAM0415\\SQLEXPRESS;DATABASE=GMT_KJ"
2¡¢½¨¶à¸öµÄʱºò£¬²»ÄܽâÎö¡£ tnsping ÃüÁî×ܲ»Í¨¹ý¡£
ÕÒÁ˺ܶ࣬ͬһ¸öÌû×Ó£¬×ªÁËÎÞÊý´Î¡£¡£
°¦¡£¡£ÖйúµÄ ......
C#Á¬½ÓOracleÊý¾Ý¿â×Ö·û´®
http://developer.51cto.com
2009-08-20 17:55 ØýÃû °Ù¶È¿Õ¼ä ÎÒÒªÆÀÂÛ(
0
)
C#Á¬½ÓOracleÊý¾Ý¿âÒÔ¼°C#Á¬½ÓOracleÊý¾Ý¿â×Ö·û´®µÈÄÚÈݽ«ÔÚ±¾ÎÄÖÐÕ¹ÏÖ£¬Ï£Íû±¾ÎÄÄܶԴó¼ÒÁ˽âC#Á¬½ÓÊý¾Ý¿âÓÐËù°ïÖú¡£
C#Á¬½ÓOracleÊý¾Ý¿â×Ö·û´®£¨²éѯÊý¾Ý£©
using
Syst ......