Skip to content

Commit 7b50c5c

Browse files
authored
Update README.md
1 parent cbfd71b commit 7b50c5c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,33 @@ body_filter_by_lua_file conf/lua/minify/minify.lua;
6262
#more config settings and some server stuff
6363
}
6464
```
65+
66+
67+
# Building your own regex rules to apply inside this script :
68+
69+
Using my code examples below copy and paste them to test and edit and build your own regex on the Lua demo site here :
70+
71+
https://www.lua.org/cgi-bin/demo
72+
73+
#### Examples :
74+
75+
##### Basic :
76+
```
77+
local string = "<style>lol1/* ok lol */lol2</style>"
78+
local regex = "<style>(.*)%/%*(.*)%*%/(.*)</style>"
79+
local replace_with = "<style>%1%3</style>"
80+
local output = string.gsub(string, regex, replace_with)
81+
print(output)
82+
```
83+
84+
##### Advanced :
85+
```
86+
local add_to_string = [[added me!]]
87+
local string = [[<style>lol1/* ok lol */lol2</style>]] .. add_to_string .. [[
88+
hello world!
89+
]]
90+
local regex = "<style>(.*)%/%*(.*)%*%/(.*)</style>"
91+
local replace_with = "<style>%1%3</style>"
92+
local output = string.gsub(string, regex, replace_with)
93+
print(output)
94+
```

0 commit comments

Comments
 (0)