简体   繁体   中英

How to extract the same Word multiple time from a String using Regular Expression withou knowing how often the Word occures in the String

I have a Problem that could be solved using Regular Expresion. I have a String that contains some substring that all contains the Word "kago". It looks like this

"ka_begin_dido_kon_ti | be_doit_ kago _end_do | bin_begin_niko_end_se | ho_begin_ kago _log_lo |du_nonit_ kago _si_ki"

Now I wrote aRegular Expresion that findes the first "kago"

.*(([a-zA-z]+_)+kago(_[a-zA-z]+)+ ).*

Output: be_begin_kago_end_do

The Problem is I can extract with this one only the First "kago" Word and not also the second or third (it can be up to 10 "kago" words in one String). How can i extract multiple times the "kago" word without knowing how often it repeats in the String?

I want to have as Output something like this:

"be_doit_ kago _end_do | ho_begin_ kago _log_lo | du_nonit_ kago _si_ki"

使用简单的\\ w尝试此正则表达式-可以接受任何字母数字字符

\w_kago_\w

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM