skip to main | skip to sidebar

Thought Home of Mr.Solo

Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts

Monday, November 22, 2010

bash中使用if语句判断字符串是否匹配正则表达式

if [[ $var =~ 正则表达式 ]]; then
echo 'find it'
fi

需要注意的是
1.两个[]
2.=~前后都有空格
3.正则表达式形式省略了//
Posted by Mr.Solo at 3:01 PM No comments:
Labels: bash, linux, regular expression
Older Posts Home
Subscribe to: Posts (Atom)

Blog Archive

  • ▼  2014 (1)
    • ▼  February (1)
      • Cscope Issue: duplicate cscope database not added
  • ►  2013 (1)
    • ►  July (1)
  • ►  2012 (2)
    • ►  August (1)
    • ►  February (1)
  • ►  2011 (5)
    • ►  November (2)
    • ►  May (1)
    • ►  April (1)
    • ►  January (1)
  • ►  2010 (4)
    • ►  November (3)
    • ►  January (1)
  • ►  2008 (4)
    • ►  September (1)
    • ►  August (3)

About Me

Mr.Solo
View my complete profile