Positive Lookahead Regex
Matches words followed by a specific pattern using positive lookahead.
パターン
/\w+(?=\s+dollars)/gi
→ ビジュアライザーで開くテスト例
100 dollars, 200 euros, 50 dollars, 75 yen
コード例
javascript
const regex = /\w+(?=\s+dollars)/gi; const result = str.match(regex);
python
import re pattern = re.compile(r'\w+(?=\s+dollars)', re.IGNORECASE) result = pattern.findall(text)
go
import "regexp" re := regexp.MustCompile(`(?i)\w+(?=\s+dollars)`) result := re.FindAllString(text, -1)
lookaheadadvancedtutorial