Cleaning Livecode Help

For a **wiki-like, hand-entered pattern**, you’ll want the pattern to be forgiving with whitespace around the brackets, the pipe, and the words, e.g.:

(<\s*[^|>]+(?:\s*\|\s*[^>]+)?\s*>)

1. `<cat>` (just a word in brackets, with optional whitespace) 2. `<cat|cats>` (with optional whitespace and pipe/plural, as before)

# What does it match?

- `<function(control structure)>` - `<cat>` - `<cat|cats>` - `<function | function()>` - `< word | words >`

# Explanation - `<\s*` — opening angle bracket, optional spaces - `[^|>]+` — one or more characters that are **not** `|` or `>` - This is your *left* element: it can be `cat`, `function(control structure)`, `something123`, etc. - `(?:\s*\|\s*[^>]+)?` — *optional* non-capturing group: - matches the pipe (with optional spaces) and anything that is **not** `>` (the *right* element) - `\s*>` — optional spaces, closing angle bracket

# What does it match? - `<function(control structure)>` - `<cat>` - `<cat|cats>` - `<function | function()>` - `<cat | cats >` - `<cat|cat's>`

# LiveCode Example

put "<function(control structure)>" into tStr put "(<\s*[^|>]+(?:\s*\|\s*[^>]+)?\s*>)" into tPattern if matchText(tStr, tPattern, tFull) then answer "Full match:" && tFull end if

# Advanced

If you still want to capture the left and right elements separately: ```regex <\s*([^|>]+)(?:\s*\|\s*([^>]+))?\s*> ``` * Group 1: left of pipe (e.g. `function(control structure)`) * Group 2: right of pipe (e.g. `cats`, or `function()`) (may be empty if not present)

# See