Monday 26 April 2010

How to split by a line delimited by Ctrl-chars

I want to split a line seperated by a delimiter "^A" and collect into an array. Writing direct control - A character in split() will not work. Control character should be written using \c[char] .

Here are some variables which use "\" (escape sequence) :

1. \a Alarm (beep)
2. \e Escape
3. \f Formfeed
4. \n Newline
5. \r Carriage return
6. \t Tab
7. \037 Any octal ASCII value
8. \x7f Any hexadecimal ASCII value
9. \x{263a} A wide hexadecimal value
10. \cx Control-x
11. \N{name} A named character
12. \N{U+263D} A Unicode character by hex ordinal
14. \l Lowercase next character
15. \u Titlecase next character
16. \L Lowercase until \E
17. \U Uppercase until \E
18. \Q Disable pattern metacharacters until \E
19. \E End modification

Read this perl regex reference manual



No comments:

Post a Comment

Tweets by @sriramperumalla