700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > oracle查找和替换正则 PL/SQL Developer的查找/替换功能中怎样使用正则表达式?

oracle查找和替换正则 PL/SQL Developer的查找/替换功能中怎样使用正则表达式?

时间:2018-09-14 21:56:23

相关推荐

oracle查找和替换正则 PL/SQL Developer的查找/替换功能中怎样使用正则表达式?

换个工具试试看?

偶这里TOAD8.5是支持的,这是toad中的帮助说明:

Regular Expression Searches

On the Find or Replace dialog boxes, you can check the Regular Expressions check box to use regular expression syntax for your search. Regular expressions can be used to specify text by its characteristics rather than by the exact characters.

Basic Regular Expression Searches

Some of the basic uses for a regular expression search include: finding tabs and replacing them with spaces. The following are some basic regular expressions:

Expression

Meaning

\r

Carriage return

\n

New line

\f

Form feed

\t

Tab character

\b

Backspace

\s

Whitespace character

\S

Space

Advanced Regular Expression Searches

You can also use regular expressions for more advanced searches. For example, to find all identifiers in a PL/SQL program, it is known that the identifier can only start with certain characters and thereafter can contain only certain other characters. Regular expressions allow the specifications of such items through the use of a syntax borrowed from tools such as GREP, LEX and YACC.

The syntax definition uses EBNF notation. EBNF (Extended Backaus-Naur Form) is a style of specification used for formal syntax descriptions. Within the syntax description the following meta-characters are used:

meta-character

meaning

a ::= b

Construct a is defined by construct b

[a]

Indicates that construct a is optional

(abc)

Indicates that constructs a, b and c are taken as a single construct

a|b

Indicates either construct a or construct b

'abc'

The literal characters 'a' followed by 'b' followed by 'c'

Single syntax construct a defined in the specification

REGULAR EXPRESSION SYNTAX

The formal description of the syntax supported is given as:

::= [ '^' ] [ '$' ]

::= [ '|' ]

::= [ ]

::= [ ]

::= |

|

|

'.' |

( '(' ')' )

::= '"' '"'

::= [ ]

::= '[' [ '^' ] ']'

::= [ ]

::= [ '-' ]

::= '*' |

'+' |

'?' |

::= |

::= '\'

::= 'x' |

'0' |

'n' |

't' |

'r' |

'b' |

'f' |

's' |

::= [ ]

::= '0' | '1' | '2' | '3' | '4' | '5' | '6' |'7' | '8' | '9' |

'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F'

::= [ ] [ ]

::= '0' | '1' | '2' | '3' | '4' | '5' | '6' |'7'

::= Any visible character (See note 1)

NOTES

specifications of grammar characters, such as '*', '?' and so on, should be escaped to prevent misinterpretation.

specifications must result in an 8 bit value. At most 3 s will be used to determine the , any more will be parsed as s after the . If the results in a character value > 255 (such as \0377) then an error will be reported.

will only accept at most 2 hex digits, any following s will not be used in the escape value and will be interpreted as s. To remove ambiguity, always use a 2 digit hex code such as \x0F and so on.

The s are interpreted as follows:

'*'

Zero or more of

'+'

One or more of

'?'

Zero or one of (i.e. optional)

A caret (^) at the beginning of a regular expression matches the start of a line. A dollar ($) at the end of an expression matches the end of the line. Both do NOT include the line start/end markers in the recognized text.

The letters can be upper or lower case and are interpreted as follows:

\r

Carriage return (ASCII code 10)

\n

New line (ASCII code 13)

\f

Form feed (ASCII code 12)

\t

Tab character (ASCII code 9)

\b

Backspace (ASCII code 8)

\s

Space (ASCII code 32)

REPLACEMENT TEXT SYNTAX

Replacement text is defined by:

::=

::= [ ]

::= |

|

::= '%'

::= [ ]

::= '0' | '1' | '2' | '3' | '4' | '5' | '6' |'7' | '8' | '9'

NOTES

and are as in the regular expression syntax.

The should evaluate to a number in the range 1..10. The upper value may be changed by purchasers of the source code.

EXAMPLES

Locate Internet references

("http://"|"mailto:"|"ftp://&quot

[^ \n\r\"\

Would allow the detection of Internet references that start with 'http://', 'mailto:' or 'ftp://'. The will be assigned based upon the syntax element and devolve to:

%1.....("http://"|"mailto:"|"ftp://&quot

%2.....[^ \n\r\"\

In English, the expression reads:

"Find all occurrences of text that start with 'http://', 'mailto:' or 'ftp://' and are followed by at least one character that is not one of a space (\s), a newline(\n), a carriage return(\r), a quote(\&quot

, a bracket (\&lt

, or a slash (\\)"

Locate all compiler directives in an Object Pascal program

"{$"[a-zA-Z_]+[\s\t\r\n]*[^\}]*"}"

Would create fields as below:

%1....."{$"

%2.....[a-zA-Z_]+

%3.....[\s\t\r\n]*

%4.....[^\}]*

%5....."}"

In English, the expression reads:

"Find all occurrences of text that start with a curly brace and a dollar ("{$&quot

and are followed by at least one letter or underscore ([a-zA-Z_]+) optionally followed by some whitespace ([\s\t\r\n]*)optionally followed by any number of anything except a close curly brace ([^\}]*) and terminated by a close curly brace "}".

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。