Find double digit number on either side of keyword

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
steve1040
Posts: 39
Joined: Fri Oct 13, 2006 2:19 am

Find double digit number on either side of keyword

Post by steve1040 »

Row1 = cooperative. he scored 25/30 on the m_m_s_e. language was fluent. he denies
Row2 = status, cognition, and cortical functions: m_m_s_e 21/30 · ****** status (including orientation to

each row contains the keyword "m_m_s_e"
I want to return the 2 digit value that may appear on either side of the keyword
between the space and "/"

So for row1 I'd get 25
and row2 I'd get 21
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

How do you want to handle these MMSE scores?

If there is at most one score on a line and if you want to replace each line that contains a score with just the score, try:
Find what: .*?(?:\b(\d\d)\b.*m_m_s_e|m_m_s_e.*?\b(\d\d)\b).*
Replace with: $1$2
If you also want to remove lines that do not contain a score, try:
Find what: .*?(?:\b(\d\d)\b.*m_m_s_e|m_m_s_e.*?\b(\d\d)\b).*(\n)|.*\n
Replace with: $1$2$3
If you can rely just on the presence of the /30 part (as MMSE scores are always out of 30), these are simpler:
Find what: .*?\b(\d\d)/30.*
Replace with: $1$2
Find what: .*?\b(\d\d)/30.*(\n)|.*\n
Replace with: $1$2$3
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Were these suggestions useful?
Post Reply