43 lines
		
	
	
	
		
			1,004 B
		
	
	
	
		
			Text
		
	
	
	
	
	
		
		
			
		
	
	
			43 lines
		
	
	
	
		
			1,004 B
		
	
	
	
		
			Text
		
	
	
	
	
	
| 
								 | 
							
								VAR='[[:alpha:]]'
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								[[ $VAR =~ '[[:alpha:]]' ]] && echo match 1
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								[[ a =~ '[[:alpha:]]' ]] || echo match 2
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								[[ a =~ [[:alpha:]] ]] && echo match 3
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								[[ a =~ $VAR ]] && echo match 4
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								[[ a =~ "$VAR" ]] || echo match 5
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								line=aab
							 | 
						||
| 
								 | 
							
								[[ $line =~ [[:space:]]*(a)?b ]] && echo match 6
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								V="alphabet"
							 | 
						||
| 
								 | 
							
								[[ $V == alphabet ]] && echo yes 1
							 | 
						||
| 
								 | 
							
								[[ $V == "alphabet" ]] && echo yes 2
							 | 
						||
| 
								 | 
							
								[[ $V == 'alphabet' ]] && echo yes 3
							 | 
						||
| 
								 | 
							
								[[ $V =~ alphabet ]] && echo yes 4
							 | 
						||
| 
								 | 
							
								[[ $V =~ "alphabet" ]] && echo yes 5
							 | 
						||
| 
								 | 
							
								[[ $V =~ 'alphabet' ]] && echo yes 6
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								DOG="Dog name - 01 - Wiggles"
							 | 
						||
| 
								 | 
							
								REPAT='([[:alpha:][:blank:]]*)- ([[:digit:]]*) - (.*)$'
							 | 
						||
| 
								 | 
							
								if [[ $DOG =~ ([[:alpha:][:blank:]]*)-\ ([[:digit:]]*)\ -\ (.*)$ ]]
							 | 
						||
| 
								 | 
							
								then
							 | 
						||
| 
								 | 
							
								   echo Dog ${BASH_REMATCH[2]} is ${BASH_REMATCH[3]}
							 | 
						||
| 
								 | 
							
								fi
							 | 
						||
| 
								 | 
							
								if [[ $DOG =~ $REPAT ]]
							 | 
						||
| 
								 | 
							
								then
							 | 
						||
| 
								 | 
							
								   echo Dog ${BASH_REMATCH[2]} is ${BASH_REMATCH[3]}
							 | 
						||
| 
								 | 
							
								fi
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								[[ $REPAT =~ "$REPAT" ]] && echo rematch 1
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								v="one two buckle my shoe"
							 | 
						||
| 
								 | 
							
								[[ ${v} =~ "one two" ]] && echo matches 7
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								[[ ${v} =~ (one two) ]] && echo matches 8
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								[[ ${v} =~ one\ two ]] && echo matches 9
							 |