SEARCH W7R

Monday, January 14, 2013

Regex Tutorial 1: Literal Text

w7r.blogspot.com

What is Literal Text?

Literal text is what it sounds like "literal text". Literal text is kind of a WYSIWYG method of capturing data from documents. WYSIWYG stands for What You See is What You Get.

Example #1: Literal Text

Regular Expression Pattern 132
Document text "abc123 321 132 1 3 2 1,32 1321321221"
Findings"abc123 321 132 1 3 2 1,32 1321321221"
Caught text "132", "132", "132"

Importance of Literal Text

You may be thinking, "That's not regex!"; however, literal text is the foundation for regular expressions, and understanding the idea of a literal piece of text is essential for understanding regular expressions.

Example #2: Literal Punctuation

Regular Expression Pattern !!
Document text "How does this work!!?? Is it working!? I hope so!!"
Findings "How does this work!!?? Is it working!? I hope so!!"
Caught text "!!", "!!"

No comments: