In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Detailed explanation of Oracle regular expression example
Split by line requirements in FORM development: the split lines should be regular and sorted according to the front and back levels
The requirements analysis is as follows:
Existing lines: 2, 2.1, 2.2, 2.3 3
2.1.1, 2.1.2, 2.1.3, 2.2.1, 2.1.1.1, 2.1.1.2
The result of splitting 2 should be 2.4 (2.4 is obtained by looking at the history record that begins with 2, there is one decimal point, the maximum value after the decimal point is + 1, and the suffix that is both a new line is obtained. ensure that the split is incremented in order)
The result of splitting 2.1 should be: 2.1.4 first make sure that the next line of each split is one more decimal place.
When comparing objects with 2.1 split to get the maximum suffix, you should match the prefix with 2.1 and only two decimal places (excluding cases where the prefix does not match: 2.1.1.1, 2.1.1.2)
To split 3, there is no history that starts with 3. This is the time to start splitting again: the result should be 3.1.
The key here is to match the history to compare and determine the maximum value of the last bit after the split.
Matching can not be judged by the number of digits, because the number may be two digits, three digits, should be judged by the decimal point
Regular expressions are used for matching:
Oracle's regular expression function, like PHP and Python, is mainly implemented by four functions: similar matching, location search, getting matching substrings, and replacing matching results (most important).
(1) similar matching: regexp_like ()
Regexp (source_str,pattern,match_parameter)
First parameter: original string, second parameter matching pattern, third parameter matching option
The third parameter matching option should work similarly in all these functions (optional)
Commonly used: I: case insensitive; c: case sensitive; n: period. Mismatch newline symbol
M: multiline mode; x: extended mode, ignoring white space characters in regular expressions.
True is returned if the match is successful. If it fails, it returns false.
My use:
IF REGEXP_LIKE (DEL_LINE_NUMBER,'^\ d *\.\ d *\.\ d *') THEN-matches a number with only two decimal points, a string
The symbols in the pattern indicate that the pattern needs to be enclosed in a pair of double quotes
^ marks the beginning of the string, and $indicates the end of the string.
\ d match a number 0-9 * the number matches the previous character 0 or more times
\. Match a period, because the period has other meanings, so use\ as an escape
(2) locate and find the character position: regexp_instr ()
Regexp_instr (source_string, pattern,position,occurrence, return_option, match_parameter) source_string: enter the string pattern: regular expression position: identifies the character from which the regular expression matches. (default is 1) occurrence: identifies the matching group. (default is 1) return_option:0-- returns the position where the first character appears. The starting position of the next character in 1:pattern. Match_parameter: matching pattern
The first two fields must be entered:
Regexp_instr () select str, regexp_instr (str,'\.') ind, start with the first character and find the first one by default. Number, you can also match the qualified string, write the matching format, not necessarily a single character regexp_instr (str,'\.', 1Magazine 2) ind, starting from the first character, look for the second. The position of the number regexp_instr (str,'\.', 5 ind 2) starts with the fifth character and looks for the second. Note that the position of the final character and string found is relative to the starting position of the search string fromtmp where id='instr';STR IND IND IND--192.168.0.48 10 select regexp_instr ('192.168.0.1, 1 grade) ind,-- period. The location regexp_instr ('192.168.0.1 minute fromdualconnectbylevel'\ dcoach grammar 1pm level) ind-- the position fromdualconnectbylevel of each number
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.