Help is asked for, with two Regex expressions

General questions about using TextPad

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

Post Reply
User avatar
ineuw
Posts: 191
Joined: Sun Mar 18, 2007 3:23 pm

Help is asked for, with two Regex expressions

Post by ineuw »

/[{}[\]^]+/g,

The above Regex expression is copied from a javascript function and need to eliminate the global search for open and close square braces. [] and leave the other parameters. I can only recognize the close brace but not the open.

/[{}[\]^]+/g,

In reverse, I need a Regex expression in which ONLY the open and close square braces. [] are searched for regardless of their position.

Thanks in advance for any help.
TextPad 8.16.0 64bit in English and TextPad 9.1.0 64bit in French, on two separate Windows installations
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

I don't entirely understand what you want.

To search for (curly) braces use
[{}]
that is, either a { or a } .

To search for (square) brackets use
[[\]]
that is, either a [ or a (quoted) ] ,
or
[][]
that is, either a ] (which doesn't need to be quoted here as it's the first character in the character set) or a [ .

Edit: Corrected typo.
Last edited by ben_josephs on Sun Jan 31, 2016 9:21 pm, edited 1 time in total.
User avatar
ineuw
Posts: 191
Joined: Sun Mar 18, 2007 3:23 pm

Post by ineuw »

ben_josephs wrote:I don't entirely understand what you want.

To search for (curly) braces use
[{}]
that is, either a } or a { .

To search for (square) brackets use
[[\]]
that is, either a [ or a (quoted) ] ,
or
[][]
that is, either a ] (which doesn't need to be quoted here as it's the first character in the character set) or a [ .
Much thanks for the clarification. I didn't know which square brace did what, as well as what the caret ^ and the plus + sign meant in the context, as well as the first forward slash, (I did know that /g meant global). I meant to separate the expressions where one is to be for the square braces and the other is for the curly braces. Now it's all clear to me. Thanks again.
TextPad 8.16.0 64bit in English and TextPad 9.1.0 64bit in French, on two separate Windows installations
Post Reply