---
# System prepended metadata

title: '[ruby][regEx]取代所有非英文的字元'
tags: [regEx, ruby]

---

# [ruby][regEx]取代所有非英文的字元

###### tags: `ruby`,`regEx`


```ruby
txt="這是中文abcde"
txt=txt.gsub(/\P{ASCII}/, '')
p txt #=>"abcde"
```