Cov txheej txheem:

Puas yog regex ib txoj hlua?
Puas yog regex ib txoj hlua?

Video: Puas yog regex ib txoj hlua?

Video: Puas yog regex ib txoj hlua?
Video: Душевой поддон под плитку своими руками. ПЕРЕДЕЛКА ХРУЩЕВКИ от А до Я #21 2024, Plaub Hlis Ntuj
Anonim

Cov ntawv luv rau kev qhia tsis tu ncua yog regex ua . Cov qauv kev tshawb nrhiav tuaj yeem yog txhua yam los ntawm tus cwj pwm yooj yim, ruaj txoj hlua los yog ib qho kev nthuav qhia uas muaj cov cim tshwj xeeb piav txog tus qauv. Tus qauv txhais los ntawm tus regex ua tej zaum yuav phim ib los yog ob peb zaug los yog tsis tag rau ib tug muab txoj hlua.

Tsis tas li ntawd, dab tsi yog A hauv regex?

Txhua tus cwj pwm hauv a kev qhia tsis tu ncua (uas yog, txhua tus cwj pwm hauv txoj hlua piav txog nws tus qauv) yog ib qho metacharacter, muaj lub ntsiab lus tshwj xeeb, lossis tus cwj pwm tsis tu ncua uas muaj lub ntsiab lus. Piv txwv li, nyob rau hauv lub regex ua a., a yog tus cwj pwm literal uas phim 'a', thaum '.

Koj pom qhov ntev ntawm txoj hlua hauv regex li cas? Rau kuaj tus ntev ntawm a txoj hlua , ib txoj hauv kev yooj yim yog sim tawm tsam a kev qhia tsis tu ncua uas pib thaum pib nrog a ^ thiab suav nrog txhua tus cim mus txog thaum kawg los ntawm kev ua tiav nrog ib $.

Ib sab saum toj no, kuv yuav ua li cas phim tus cwj pwm tshwj xeeb hauv regex?

Sib phim txhua tus cim tshwj xeeb hauv ib txheej

  1. Siv square brackets kom phim cov cim hauv ib txheej.
  2. Siv w kom phim ib tus lej lej: 0-9, a-z, A-Z, thiab _ (underscore).
  3. Siv d kom phim ib tus lej.
  4. Siv s kom phim ib tus cim whitespace.

regex ua haujlwm li cas?

A kev qhia tsis tu ncua , regex ua los yog regexp luv luv, yog ib ntu ntawm cov tsiaj ntawv thiab cov cim uas txhais cov qauv kev xav. Cov hlua ntawm cov ntawv tuaj yeem muab piv rau tus qauv txhawm rau txheeb xyuas cov hlua uas phim cov qauv kev xav tau txhais los ntawm regex ua.

Pom zoo: