[英]Regex Pattern using Perl5Matcher
我正在嘗試為以下字符串編寫模式匹配器
show int sh 1/1/06
SHDSL 1/1/6
Description 3599979
Constellation (bits/baud) 30
我需要獲取'show int sh'和'SHDSL'和'Description'等的值...
它應該縮小空格並獲得相應字符串的值。
任何人都可以指導我編寫相同的正則表達式模式嗎?
您可以在多行模式下使用此正則表達式
^show int sh\\s*(.*)$
^show int sh\\s*
檢查所需數據之前的行開始^
處的show int sh
\\s*
匹配0或更多空格,直到第一個非空格字符
(.*)$
捕獲所需的值,直到組1中的 $
行結束
所以這是所有正則表達式的
使用多行模式
^show int sh\\s*(.*)$
^SHDSL\\s*(.*)$
^Description\\s*(.*)$
^Constellation\\s*(.*)$
或單個正則表達式
^((show int sh|SHDSL|Description|Constellation)\\s*).*$
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.