User Tools

Site Tools


kurs:regular_expression

Ermitteln ob in einer Spalte/Usereingabe eine PLZ steht

select 'ist eine PLZ' from dual 
-- select coalesce(plz, 'n/a') from adressen
-- where regexp_like('assaa-223421213', 'a-2234') -- ist enthalten
-- where regexp_like('a-2234', '[Aa]-2234') -- grosses oder kleines A
-- where regexp_like('A2234', '[Aa][ -]*2234') -- * keines oder beliebig viele
-- where regexp_like('A2234', '[Aa][ -]{0,1}2234') -- 0 oder eines aus der Gruppe
-- where regexp_like('A2123', '[Aa][ -]{0,1}[0-9]{4}') -- {x} genau x mal
-- where regexp_like('A2123', '[Aa][ -]{0,1}\d{4}') 
-- statt der Gruppe character class http://perldoc.perl.org/perlrecharclass.html
where regexp_like('A2123', '^[Aa][ -]{0,1}\d{4}$') 
select 1 from dual where regexp_like('A-   - 1234', '^A(-| ){0,}[[:digit:]]{4}$')

select regexp_instr('A-   - 1234', '^A(-| ){0,1}[[:digit:]]{4}$') from dual

select regexp_substr('am parkweg 27, A-1234, Stadtdorf', 
                     'A(-| ){0,1}[[:digit:]]{4}') as plz from dual

select regexp_instr('Mark Hofstetter', ' ') from dual

select 1 from dual where 'Mark' like '%M%';

select regexp_replace('Blastr. 27', '[[:blank:]]+', ' ') from dual;

select regexp_replace(regexp_replace('Bla   Str.      27', '(str).',  '\1asse',1,1,'i'), '[[:blank:]]+', '_') from dual;


regexp_like(PLZ, '^A(-| ){0,}[[:digit:]]{4}$') or regexp_like(PLZ, '^D(-| ){0,}[[:digit:]]{5}$')
kurs/regular_expression.txt · Last modified: 2017/03/21 10:02 by admin