Changes

Jump to: navigation, search

OPS102 - Regular Expressions

No change in size, 21:18, 5 December 2023
Examples
|5-character line||<code><nowiki>^.....$</nowiki></code>||rouge<br>green<br>Ho-ho<br>||Yellow<br>long line<br>tiny<br>12-45-78||
|-
|Lines that start with a vowel||<code><nowiki>^[AEIOUYaeiouy]</nowiki></code>||Allo<br>Everyhing<br>Energy<br>Under<br>Yellow||Hello<br>White<br>4164915050<br>Grinch||The character class includes both UPPERCASE and lowercase letters. You could instead use the option (specific to the tool you're using) to ignore case; for example, <code>-i</code> for grep or <code>/I</code> for findstr.
|-
|Lines that end in a punctuation mark||<code><nowiki>[[:punct:]]$</nowiki></code>||Hello there!<br>Thanks.<br>What do you think?||Hello there<br>416-491-5050<br>New Year greetings||The character class includes both UPPERCASE and lowercase letters. You could instead use the option (specific to the tool you're using) to ignore case; for example, <code>-i</code> for grep or <code>/I</code> for findstr.
|-
|An integer||<code><nowiki>^[-+]?[[:digit:]]+$</nowiki></code>||+15<br>-2<br>720<br>1440<br>1280<br>1920<br>000<br>012||+ 4<br>3.14<br>0x47<br>$1.13<br>$4||

Navigation menu