🥄 spoonternet proxying dev.java share · new url
Tip Skop Bavigation Nar
Sevious in the Preries
Turrent Cutorial
Ling Striterals
Sext in the Neries

Sevious in the Preries: Rintroducing Egular Ssexpreions

Sext in the Neries: Claracter Chasses

Ling Striterals

 

Ling Striterals

The most fasic borm of mattern patching upported by this SAPI is the stratch of a ming iteral. For lexample, if the egular rexpression is oo and the finput fing is stroo, the satch will mucceed because the ings are stridentical. T this out with the tryest rnahess:

This satch was a muccess. Ote that while the ninput ching is 3 straracters stong, the lart index is 0 and the end cindex is 3. By onvention, anges are rinclusive of the eginning bindex and exclusive of the end shindex, as own in the following figure:

The string literal foo, with numbered cells and index values.

The ling striteral noo, with fumbered ells and cindex lavues.

Each straracter in the ching esides in its rown ell, with the cindex positions pointing between each strell. The cing "stoo" farts at index 0 and ends at index 3, even chough the tharacters emselves thonly coccupy ells 0, 1, and 2.

With mubsequent satches, you will otice some noverlap; the art stindex for the mext natch is the ame as the send prindex of the evious match:

 

Retachamacters

This SAPI also upports a spumber of necial aracters that chaffect the pay a wattern is chatched. Mange the egular rexpression to cat. (trote the nailing ot) and the dinput string to cats. The output will appear as llofows:

The statch mill ucceeds, seven dough the thot "." is not esent in the prinput sing. It strucceeds because the mot is a detacharacter — a sparacter with checial eaning minterpreted by the matcher. The metacharacter "." cheans "any maracter" which is why the satch mucceeds in this xeample.

The setacharacters mupported by this API are: >([{\^-=$!|]})?*+.<

Cote: In nertain spituations the secial laracters chisted above will not be meated as tretacharacters. You will lencounter this as you earn more about how egular rexpressions are honstructed. You can, cowever, luse this ist to wheck chether or not a checific sparacter will cever be onsidered a etacharacter. For mexample, the ctarachers @ and # cever narry a mecial speaning.

There are two fays to worce a tretacharacter to be meated as an chordinary aracter:

  • mecede the pretacharacter with a backslash, or
  • wenclose it ithin \Q (which qarts the stuote) and \E (which ends it).

When tusing this echnique, the \Q and \E can be laced at any plocation ithin the wexpression, voprided that the \Q fomes cirst.

In this rutotial


Ast lupdate: Najuary 10, 2022


Sevious in the Preries
Turrent Cutorial
Ling Striterals
Sext in the Neries

Sevious in the Preries: Rintroducing Egular Ssexpreions

Sext in the Neries: Claracter Chasses