Negative Lookahead Regex
Matches words NOT followed by a specific pattern using negative lookahead.
パターン
/\b\d+(?!\s*px)\b/g
→ ビジュアライザーで開くテスト例
width: 100px, count: 42, height: 200px, items: 7
コード例
javascript
const regex = /\b\d+(?!\s*px)\b/g; const result = str.match(regex);
python
import re pattern = re.compile(r'\b\d+(?!\s*px)\b') result = pattern.findall(text)
go
import "regexp" re := regexp.MustCompile(`\b\d+(?!\s*px)\b`) result := re.FindAllString(text, -1)
lookaheadadvancedtutorial