/
(?#
# Adapted for PHP by Paul Buonopane of NamePros https://www.namepros.com/
# Based heavily on the following works:
# - https://manishearth.github.io/blog/2018/02/15/picking-apart-the-crashing-ios-string/
# - https://github.com/hackbunny/viramarama
#
# This PHP regex will match any string that contains Indic character
# combinations known to crash many iOS applications as of 11.2.5 and certain
# macOS combinations as of 10.13.3.
#
# IMPORTANT: This will only work if you use the `x` and `u` modifiers.
# Example: "{regex-goes-here}xu"
#
# COMPATIBILITY: While PHP does use PCRE, the `u` modifier isn't technically
# Perl-compatible. For this to work without the `u` modifier,
# the regex would need to be adapted to use | instead of [],
# as all of these characters are multibyte in all popular web
# encodings, e.g. UTF-8.
#
# Tracked By: rdar://37458268
# https://openradar.appspot.com/37458268
# Date Originated: 2018-02-12
# CVE ID: Unknown as of writing
#)
(?(DEFINE)
(?<zwnj> (?# You can't see me, but I'm here!))
(?<devanagari_virama> ्)
(?<devanagari_consonants> [कखगघङहचछजझञयशटठडढणरषतथदधनलसपफबभमव])
(?<devanagari_sj_consonants> [र])
(?<devanagari_pj_pairs> र(?&devanagari_virama)र)
(?<devanagari_vowels> [ऺऻािीुूृॄॅॆेैॉॊोौॎॏॕॖॗॢॣ])
(?<bengali_virama> ্)
(?<bengali_consonants> [কখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরৰলৱশষসহ])
(?<bengali_sj_consonants> [যর])
(?<bengali_pj_pairs> [রৰ](?&bengali_virama)র)
(?<bengali_vowels> [ািীুূৃৄেৈৢৣ])
(?<telugu_virama> ్)
(?<telugu_consonants> [కఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరలవళశషసహఱ])
(?<telugu_sj_consonants> (?&telugu_consonants))
(?<telugu_vowels> [ాిీుూృౄెేొోౌౢౣ])
)
(?!(?&devanagari_pj_pairs))
(?&devanagari_consonants)
(?&devanagari_virama)
(?&devanagari_sj_consonants)
(?&zwnj)
(?&devanagari_vowels)
|
(?!(?&bengali_pj_pairs))
(?&bengali_consonants)
(?&bengali_virama)
(?&bengali_sj_consonants)
(?&zwnj)
(?&bengali_vowels)
|
(?&telugu_consonants)
(?&telugu_virama)
(?&telugu_sj_consonants)
(?&zwnj)
(?&telugu_vowels)
(?#
# The license for the work on which this regex is based is provided below, with an
# additional note regarding adaptation.
#
# Copyright 2018 hackbunny <hackbunny@gmail.com>
# Adapted for PHP by Paul Buonopane
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
# software and associated documentation files [the "Software"], to deal in the Software
# without restriction,