Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Regular Expression repalace with Uppercase
#2
QM does not support \U.
Need a callback function:
menu File -> New -> Templates -> Callback -> Callback_str_replacerx.

Macro Macro2433
Code:
Copy      Help
str s=
;Tuesday-Friday 9:00 a.m. to 9:00 p.m.
;Tuesday-Friday 9:00 am to 9:00 pm
;Tuesday-Friday 9:00 AM to 9:00 PM
REPLACERX ff.frepl=&sub.Callback_str_replacerx
s.replacerx("\b(am|pm|a\.m|p\.m)\b" ff 1)
out s


#sub Callback_str_replacerx
function# REPLACERXCB&x

;Callback function for str.replacerx.
;Called each time when a match is found during replacement process. Provides replacement string.
;x.match initially contains the matched substring. This function can modify it. It will become replacement string.
;More info in QM Help.

;Return:
;0 - match is replacement string. It will be appended to string being formatted. If match is not modified, matched substring will not be replaced.
;> 0 - nothing should be appended to string being formatted. This return value can be used either to remove matched substring, or when callback function itself appends replacement to strnew.
;-1 - stop replacement process. str.replacerx will return immediately. It returns number of replacements not including current, or -1 for single replacement mode. To stop replacement process and include current replacement, set x.rr.ito = 0.
;< -100 generate error with this error number.


x.match.ucase


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)