格 千格 KiloCell

Regular Expression Tester Guide: Mark position, trap and ReDoS awareness

Update 2026-08-08 About 13 minutes development tools How-to

Regular expressions are commonly used when writing forms to validate, log resolution, and data cleansing scripts. Misuse of the sign or encounter with ReDoS (denial of service attacks) to get to the front end; The connection also raises doubts about "why not match" — this guide clearly describes the markings, traps and security boundaries, along with the actionable steps and error sheets on the KiloCell page.

Use tools immediately Regular expression test - local real time matching, high-profile, sign-point debugging
Open tool →

The core sentence.

(a) Signing control matching behaviour; And the stronger rules, the infinity cycle with ReDos.

Thousands of-gauge regular tester support g / i / m Marks, real time match and highlight. Main tool:Regular Expression Tester。

What is the regular expression doing in the project?

Regular Expression is the language that describes " string mode " . Typical uses:

  • Form authentication: Mailbox, mobile phone number, ID card, URL
  • Log/text cleansing: extracting numbers, replacing sensitive words
  • Data grab: Extract field from a web page or CSV
  • Code Completion: Highlight Keywords, Code Review

The core is... Match and Replace。 The regular engine is in the browser with JS. RegExp Achieved, slightly different from service-end languages (marking, greed, etc.).

Signs Detail

Signing position Meaning Thousands of Page Controls Typical scene
g Global (find all matches) Check flagG Replace All & & Extract All Mailboxes
i Ignore case Check flagI (?i)abc It's written.
m Multiline Mode Check flagM ^ Match the beginning of each line, $ Match the end of each line
s / u (JS unique) None (b) Be careful; Browser Default s Open

Page Default g, other may be ticked as required. Real time input triggers runRegex()Left Regular Box / Mark, right-hand match results with high-profile results.

What do you do on the 1,000?

tools page:Regular Expression Tester。

Base Match

  1. Open the page.
  2. Left Regular expression (Pattern) Input /pattern/ Or write it directly. pattern(tools slash).
  3. Right Test Text Paste sample examples.
  4. Check out the signpoint.
  5. Pages are real time: Highlight matches on the left, and the result area on the right shows matching lines, index, group capture (if any) ())。

Replace

Most regular testers support replacement areas. - Put it on. replace text is entered and can be copied directly.

Capacity boundaries

  • Yes: Three markers are controlled in real time, with high-light matching, capture group display, text replacement, and reset.
  • None: Complete u Signing (BX default is open), extremely complex nesting group or s Mark bits fine.
  • No substitute: The security claim under the very slow rule (ReDoS) is not a valid one. Performance is improved by using CLI or backend engines.

Common error and contrast

phenomena Reason Processing
I've only got the full text. groups Empty The sign is not ticked or written correctly Confirm. g、i、m Correct; Page Real Time Feedback
^ Match the whole string instead of every line Not marked m Check. m Or use it. \A
The infinite cycle causes the page card to die. ReDoS(.* Greed + Match Failed) Change .*? Lazy or borderline; Large text suggested batch
Get your cell number. 1\d{10} 11 bits No, I'm not. \b Border Add \b or (?<!\d)\d{11}(?!\d)
Mailbox Match ^[\w.]+@[\w.]+ Leak + No, no, no. Incomplete character set Use [\w.+-]+ Or third-party library
Line Break Missing after Replace Not considered \n Conversion Clear replacement template \n
Missing after page reloading Signing position not sustained Recheck; or write the regular to the URL parameter

Wrong order

  1. Confirms whether the sign position matches the backend engine (JS vs Python, etc.).
  2. Test minimum replicable string, avoid .* Cut dead.
  3. Check if you need it. \b / Boundary or \s+ Change the number of spaces.
  4. Whether the group vs replacement template is as expected.

Real work scenarios

Scenario A: Form validation

Cell phone number:^1[3-9]\d{9}$(11 bits, beginning of 1). Test Text 13800138000 13912345678 Check. g Sees a match;1380013800 does not match. Pages are highlighted in real time to facilitate debugging.

scene B: Log Resolution

Extract 2026-08-08 12:00:00 INFO: user=123 . Time stamp with user name. Mode:(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2})\s+(\w+):。 Check. g can be extracted more than one.

Scenario C: Sensitive Word Replace

Replace the sensitive word in the commentary with 。 Use g Mark global replacement, replace template writing 。 Note whether changes in length after replacement affect UI.

scene D:URL extraction (coding URL)

https://example.com?a=1&b=2 Extract query parameters from:\?&=([\w%]+)。 Check. g - Yeah. Attention. & = is processed on the encoder layer.

scene E:ReDoS Presentation

Enter a malicious one. a.(Infinite) a Greed when matching failure . - It's a dead engine. Browser will be stuck or frozen. Replace with a.*? Lazy mode can be restored. page will be prompted or Qaton will be stopped manually.

Scenario F: Back and back pairs "Has it matched?"

Frontend userInput Do it. regex.test(); The back end does the same. Differences are often at the mark or ^ $ vs \A \z。 This tool is used to harmonize the two-side examples.

Security and ReDoS Awareness

  • ReDoS It's a denial of service: malicious positive input fails to match browsers for a long time.
  • Prevention: Limit the length of the regular side ({100} (b) Be careful above); With lazyness. .*?; Or backend check again.
  • . A batch is recommended when the page matches large text in real time.
  • The blogger says that the "regular rule" is not a "any string" matchmaker. Borders are important.
  • Production shall be accompanied by unit and performance tests.

List of practices

  • Production is regular. const re = new RegExp('^...' , 'gim') or /.../gim。
  • All regular tests are conducted using the minimum replica.
  • See engine error when matching failure (browser console or backend log).
  • ReDoS enters a page without longcards, suggesting that you interrupt.
  • Team agreed to a single sign:g Global,i Case,m - It's a lot of work.
  • Replace template with a special character ($1 Wait.

FAQ

Why does `^ match the whole string instead of the beginning of each line?

No hook. m Mark. Check. m Back ^ Matches the beginning of each line.

What if it's the right card?

Press browser Tab to switch or press Esc (a) Interruption; Correcting is used. .*? Lazy, or with length limits.

The mailbox is missing the `+ '?

Character Set [\w.+-]+ Including +。 The page tool has already incorporated a regular example of a normal mailbox.

Match lines less after replacement?

Replaces the template with the character. The template is confirmed as correct and reviewed.

Will online tools pass on my rules?

Pages are calculated locally, but the regular and test text may contain sensitive words. Sensitive data suggest dissensitization or use local CLI.

Is JS and Python the same thing?

The same markers vary in the degree of greed, capture group behaviour, and backtracking. Samples are aligned with backend engines.

From test sample to maintainable rule

Regular expressions are prepared for at least three sets of examples: valid inputs that must match, illegal entries that must be rejected, and boundary inputs that are close to the actual data in length and character set. Do not take a pretty sample test because the rules are likely to expose problems on empty strings, line breaks, Unicode characters or hyperlong text. Puts the sample and the rule together in the version library, and when you change the expression, you run a regression check and then update the description.

It also needs to be clear from which the object matches. Browser forms, logs, CSV and API fields may have different transversal layers and the back slash in the user input may have been processed once by JSON or JavaScript before entering the regular engine. When you are wrong, print the string you actually receive, and then check the expression text, the sign position and the input text separately. Rules from untrustworthy users are not directly enforced at the service end; Complex retrospective expressions may result in ReDoS, which should be capped, overtimed or linearly selected. Online testers are suitable for understanding rules and should not be a substitute for sandboxing and monitoring in the production environment.

Performance, replacement and version compatibility

The test matches the results with the time of implementation and the replacement results. A seemingly simple pattern in which a large number of duplicate characters can trigger index-level backtraces; Increasing the length of the sample from 1 KB to 10 KB, 100 KB, recording time-consuming changes, which are more likely to detect performance risks than simply looking at " Match Success " . The service should set maximum input length and timeout, so that the regulars submitted by the user do not fill the workspace directly.

The replacement mode also needs to be independently validated. The number of the catch group changes with brackets added to or deleted, the naming group is written differently in different languages, and the back slash may be re-transformed in the source string. Saves the original text, matching the clip, replacing the result as three columns and runs separately in JavaScript, Python or database engines. If the same rule requires cross-linguistic sharing, priority is given to the use of a common and supported basic grammar, avoiding reliance on the unique forward-looking, retrogressive or Unicode expansion of an engine.

Continue reading

It is advisable to maintain the rules by giving each expression a name and description of the purpose, such as “order extraction” or “check internal works”, without leaving only a hard-to-search word in the code. The statement is written to clear the permitted characters, maximum length, whether global matching is required, and what is displayed to the user when it fails. This way, when the brackets, markers or transliteration are subsequently changed, the reviewers will be able to judge whether the behaviour changes are business-like, rather than comparing a series of symbols with the naked eye.

Finally, the two roles of verification and extraction are distinguished. The verification rules usually require the entire paragraph to be entered with conditions from the beginning to the end, while the extraction rules concern only the local segments of the text; If you use a extract as a check, you may be wrongly released if only a part of the user name is matched. The interface layer should clearly return the boolean value, capture the group or replace the text and write the expected results on empty values, abnormal codes and multi-line input. Each adjustment retains the old and new examples, so that it becomes clear whether the rules are repairing or whether they are quietly expanding the scope of acceptance.

A "Input a → sign slot to match a → replacement" with a cell phone number is used to create a safe mind by testing a ReDoS example.