Is ?: something special in regex?

Looking at some of yanfly's regex

/<(?:REGION_BATTLEBACKS|region battlebacks)>/iI don't understand what the ?: is doing.Is there something special about it in the context of a capture group?
I'm also interested in knowing. I know that :? Would mean zero or one :, but I'm not sure about ?:
?: allows you to create match groups that capture matches without generating back-references. Basically, it's a performance optimization when you don't need access to all of the back-references that your regular expression creates -- just the most recent one.
Thanks, I see how it works.


http://rubular.com/r/OoeCIxDhOm


Though, does that performance optimization also apply when you only have one capture group?
It certainly can, depending on the string you're matching the regular expression against.
Is there a term for that notation?
Honestly, I don't know -- and I don't really see the importance of knowing the term if you know what you're doing with it, really.
It certainly can, depending on the string you're matching the regular expression against.
What kind of strings/regex would fit that bill?

I guess I'm not really understanding the point of using ?: because in this context the particular note-tag is only used as a delimiter of some sort; the captured contents are never being used anyways. So it's probably a bad example.

Some may be tempted to think that for some reason this

Code:
(?:VALUE)
is better over just

Code:
VALUE
Would be useful if you just want to detect if the string exists. So for things you're setting in notes as a flag but don't have any parameters, or for the purposes of that particular section of script, you don't care what the parameters are.
Basically, you wouldn't be using ?: for capturing a single flat value -- the point is to optimize grouping, and you certainly wouldn't need to group something like VALUE. What you're doing with ?: is minimizing the memory footprint of running a regular expression where all of the back-references that would normally be generated are legitimately unnecessary. In the example, Yanfly's regular expression matches REGION_BATTLEBACKS and region battlebacks (including all of those case-insensitive variations). Essentially, that had to be defined as a group in order to match what was needed: a group was required, but all of the back-references generated by using it were not.


Edit: Just saw this.

Would be useful if you just want to detect if the string exists. So for things you're setting in notes as a flag but don't have any parameters, or for the purposes of that particular section of script, you don't care what the parameters are.
Then you could just use string['match this'].
Looking at some of yanfly's regex

/<(?:REGION_BATTLEBACKS|region battlebacks)>/iI don't understand what the ?: is doing.Is there something special about it in the context of a capture group?
That's mean you can write your notetag like this

<ReGiOn BaTtLeBaCkS>Correct me if I'm wrong
Yes, because of the /i at the end. That's got nothing to do with the ? at the start.
That's mean you can write your notetag like this

<ReGiOn BaTtLeBaCkS>Correct me if I'm wrong
No offense, but you are incorrect. That's what the i flag at the end of the regular expression does -- it allows it to match regardless of case. (The "i" stands for "insensitive," as in "case insensitive.")

Edit: Again, the point of using ?: is to make use of match groups without generating the back-references. It's about performance.
No offense, but you are incorrect. That's what the i flag at the end of the regular expression does -- it allows it to match regardless of case. (The "i" stands for "insensitive," as in "case insensitive.")

Edit: Again, the point of using ?: is to make use of match groups without generating the back-references. It's about performance.
Well, that's something new for me ._.

Thanks anyway 😀
/<(?:REGION_BATTLEBACKS|region battlebacks)>/imeans we can write it as

<region_battlebacks>

or

<region battlebacks>

(one using space one using underscore)

so we could also use it as

/<(?:REGION_BATTLEBACKS|region battlebacks|rb|reg_battleb)>/iand we can use <rb> and <reg_battleb>

i think ?: is like "if either regexp inside the bracket match" it will grab the data.

(but it might also means just plain if and the | is the one making the or statement)

i have no actual knowledge about regexp. but it's based on experience on experimenting on regexp (combining victor, yanfly, tsukihime, mr bubble) to make my own notetags grabber script. i usually use trial and error and see what happen when we put that regexp. and i found above when seeing mr bubble script. in his notetags we can use item, armor, weapon or just i, a, w (for shorter notetags).
i think ?: is like "if either regexp inside the bracket match" it will grab the data.
No, it is what solistra has said up there.


The pipe | in the parentheses is the one that says either-or.


There are no if conditions in regex, which is why regex is not suitable for certain applications.
Since the original question has been answered ...


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/is-something-special-in-regex.17210/