0
我在表中具有下列字符串:MySQL正用空字符替換字符
^step([0-9]|[1-9][0-9]).cards.choice_step_1$
^step([0-9]|[1-9][0-9]).cards.choice_step_2$
它可能:
step1.cards.choice_step_1
step1.cards.choice_step_2
step2.cards.choice_step_1
step2.cards.choice_step_2
我會用空字符使用該模式取代所有這些字符串在MySQL中這樣做?
最後我會在結果:
1
1
2
2
編輯
select regex_replace('[^0-9]','','step1.cards.choice_step_1');
還給我
11
請在正確的方式幫助以下數據:
sometext.step1
sometext.step1.cards.choice_step_1
sometext.step1.cards.choice_step_2
sometext.step1.desire
sometext.step2
sometext.step2.cards.choice_step_1
sometext.step2.cards.choice_step_2
sometext.step2.desire
得到以下結果:
step1
step1
step1
step1
step2
step2
step2
step2
可能重複[如何在MySQL中執行正則表達式替換?](http://stackoverflow.com/questions/986826/how-to-do-a-regular-expression-replace-in-mysql) – miken32