Hive hql: from a string "P? A? B? C? PPP? Hhh "? As the separator, find the 5th string
Bash program:
Test. Sh#!/bin/bashhive -e "select (split('p?a?b?c?ppp?hhh','?'))[4] from a limit 1;"
Error:
Caused by: Java. util. RegEx. patternsyntaxexception: dangling meta character '? 'Near index 0 is changed:Test. Sh#!/bin/bashhive -e "select (split('p?a?b?c?ppp?hhh','\\\\?'))[4] from a limit 1;"
Reason for correct running:
The second parameter of split is a RegEx, and '? 'Has a special meaning (? Zero or one match with the previous character or subexpression), so it must be escaped. In Hive, '\' itself represents the escape character, so '\' needs to be escaped in bash, '\' itself represents the escape character, so '\' needs to be escapedAppendix: special characters to be escaped in a regular expressionAnnotation $ matches the position at the end of the input string. If the multiline attribute of the Regexp object is set, $ also matches the position before \ n or \ r. To match the $ character, use \ $. () Mark the start and end of the subexpression. You can capture subexpressions for future use. To match these two characters, use \ (and \). * Matches the character or subexpression zero or multiple times. To match * characters, use \*. + Match the previous character or subexpression once or multiple times. To match + characters, use \ + .. Match any single character except linefeed \ n. To match., use \. [] Mark the start of the brackets expression. To match these characters, use \ [and \].? Matches the previous character or subexpression zero or once, or indicates a non-Greedy qualifier. To match? Character, use \?. \ Mark the next character as a special character, text, reverse reference, or octal escape character. For example, CHARACTER n matches CHARACTER n. \ N matches the linefeed. Sequence \ match \, sequence \ (MATCH (. /Indicates the start or end of the text regular expression. To match/characters, use \/. ^ Matches the start position of the input string, except when used in the brackets expression. In that case, the character set is reversed. To match the ^ character itself, use \ ^. {} Mark the start of the qualifier expression. To match these characters, use \ {and \}. | Select between two items. To match |, use \ |
Bash escape tables\ A ascii Bell character (you can also type \ 007) \ D "wed Sep 06" format date \ e ASCII escape character (you can also type \ 033) the full name of the \ H Host Name (for example, "mybox") \ H host (for example, "mybox.mydomain.com ") \ J in this shell, the number of processes suspended by ^ Z \ L terminal device name of this shell (such as "ttyp4 ") \ n linefeed \ r carriage return \ s Shell Name (for example, "bash") \ t 24-hour time (for example, "23:01:01 ") \ t 12-hour system time (such as "11:01:01") \ @ 12-hour system time with AM/PM \ U User Name \ v bash version (such as 2.04) \ v bash version (including Patch Level) \ W current working directory (such as "/home/drobbins") \ W current working directory "base name (basename)" (such "Drobbins ")\! Position of the current command in the History buffer \ # command number (as long as you type the content, it will accumulate at every prompt) \ $ if you are not a Super User (Root ), insert a "$". If you are a super user, a "#" \ XXX is displayed, and a three-digit XXX is inserted (zero is used to replace unused numbers, for example, "\ 007") represents the ASCII character \ backslash \ [this sequence should appear before the Character Sequence without moving the cursor (such as the color escape sequence. It enables Bash to correctly calculate the line feed. \] This sequence should appear after the non-printable character sequence. Reference: http://www.aslibra.com/blog/read.php/1559.htmhttp://hi.baidu.com/yacker/item/52af3ca4c94873d35bf191ea