Skip to content
Home · Sonraki hedefe 100 XP
Son hareketler
Henüz bir öğrenme hareketi yok. İlk derse başlayın.

Software Engineering

Regular expressions: Matching, bounding and costing

Regex is powerful for text pattern searching; Solving every data validation task with a single complex statement can introduce maintenance and performance issues.

Bu derste neler var?

SIBERSALDIRI.COM · FOCUSED LESSON

What you will learn

  • Explain the relationship between text boundary and Pattern.
  • “Does match mean safe HTML?” To give a reasoned answer to the question.
  • Changing the example and comparing expected and observed behavior.

How it works and where the trust boundary lies

Define leading and trailing boundary in full field validation. Turn on character set, length, and Unicode behavior. Nested ambiguous repetitions can lead to excessive backtracking in some engines. Consider the parser maintained on complex formats such as email or URL. Successful matching does not provide authorization or output security.

Regular expressions: Match, bound and cost flow: Text boundary → Pattern → Bound match
Text limit → Pattern → Limited match. The diagram shows the relationship; It does not replace the entire application.

Worked example

The following passage makes the concept visible. Evaluate samples containing commands or code in your own separate testing environment, not in the production system. Architectural diagrams and policy examples are not executable programs.

<?php
$slug = 'ag-guvenligi';
$valid = preg_match('~\\A[a-z0-9-]{1,80}\\z~D', $slug) === 1;
var_export($valid);

Expected result and interpretation

The defined small ASCII slug returns true; An empty or long value is rejected.

Compare the scenarios

StatusRecommended approachWhy?
partial matchDefine exact limitThe rest of the field may be invalid
Too long inputSize limit firstExcessive cost is reduced
complex formThink differentlyRegex is not suitable for every data contract

Practice task

Add a space at the beginning and a line break at the end; Verify the exact match rule.

  1. Write down the expected outcome and acceptance condition before the action.
  2. Change a single variable; Record the observation and the medium you used.
  3. Evaluate the result with the comparison table above. Explain which assumption might be wrong if it does not fit.

Common mistake and how to correct it

Do not process unlimited length input with an expression of unknown cost.

Test your understanding

Does match mean safe HTML?

Answer explained: No. Format acceptance and encoding in the context of output are different controls.

Continue with related lessons

Technical reference

The explanation and examples of this course have been re-prepared for the academy. The link below is a technical reference to verify details of the technology or security approach used.

Bir adım daha ilerlediniz.

Dersi bitirdiyseniz tamamlandı olarak işaretleyin. İlerlemeniz bu cihazda saklanır.

Academy menu

Akademide ara

En az 2 karakter yazın.