29 lines
844 B
Plaintext
29 lines
844 B
Plaintext
#include <hopper.h>
|
|
|
|
main:
|
|
expReg="[A-Z]{1,2}[0-9][0-9A-Z]? +[0-9][A-Z]{2}"
|
|
cadena = "We are at SN12 7NY for this course"
|
|
flag compile = REG_EXTENDED
|
|
flag match=0
|
|
número de matches=10, T1=0
|
|
|
|
{flag compile,expReg} reg compile(T1) // compile regular expression, pointed whit T1
|
|
{flag match,número de matches,T1,cadena},reg match, // execute
|
|
|
|
matches=0,mov(matches)
|
|
reg free(T1) // free pointer to regular expression compiled.
|
|
|
|
From=0, To=0, toSearch=""
|
|
[1,1]get(matches), mov(From)
|
|
[1,2]get(matches), mov(To)
|
|
[1,3]get(matches), mov(toSearch)
|
|
|
|
// substitute with "transform":
|
|
{"another thing",toSearch,cadena}transform, println
|
|
|
|
// substitute with "delete"/"insert":
|
|
{To}minus(From),plus(1), {From, cadena} delete, mov(cadena)
|
|
{From,"another thing",cadena}insert , println
|
|
|
|
exit(0)
|