Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127509 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 66D6D1A00BC for ; Fri, 30 May 2025 07:42:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748590805; bh=M2wBU0iyBmzy72HE8i5mC/MWvTljXcwVjMwSbT2+gpA=; h=References:In-Reply-To:From:Date:Subject:To:From; b=d32Sk1U0hCM1zd5thSVV4Sl8SkSyR7+eouVGQpCvOi+RhXDGcKoR1qmKAagrNjHQZ pWjZhy9bAqRnIrvxu3TFPIMpPEBmfqjw1E42YP9Bt8NAsCP+eN8USOjLkzzlWoxutO fHRvG2oztRmqXfFgpTDikBYeXwi0/AhHzl5wJDG2S2BplE1vdMKkra7ORaxZ0if4PD dT7tj3RWApMB9jq0jw3dm02Wnz4iaaNTZauytoLUs5hzF2lrFrP90k8kBZxu9xuBoE QPX53SWkDP8sDiI4WCCXeRH/rEyNI628O3jzL779CNm5tXkvY5AbRFOVQnWS7BCauq avUo6GBHU/6Cw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6371318004C for ; Fri, 30 May 2025 07:40:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 30 May 2025 07:40:04 +0000 (UTC) Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-43cfa7e7f54so11814815e9.1 for ; Fri, 30 May 2025 00:42:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748590929; x=1749195729; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vP0gFMiI19/+0j+oglvUtqQ3D40Dw8KgOaRkv1bYM/E=; b=DzzFmped8ALhiUoO2vVnCtf5Mgp6RePj8+qA/yueinJhNhLqAYI+V4SYNcoNFuWsOV 4/SmAfJjVC0FkX6e7K4FogZdUoC3Tl8PbGLR/KfD6a3VIzKNmWe3yPq+lnmLc7GgQNdS 6Y1bjDQTGZmqM+/1InVZPdeXWwGWC5T4sniFZFchn34v+kr/VgPNP5ZcNwUYYgDMnc8H dvEiCO7v7G6c8TA/xomq1IbTfyS0qR3TKXI83scQFZEaMaNja4eGB368kR0v2+vIzrDD RkdSptppUrPE4jiPxC8QIwkKHdKQFab/gc2KFrg6IU6DxYeg5A5OTRq3uRC09z1OkjlO tufQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748590929; x=1749195729; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vP0gFMiI19/+0j+oglvUtqQ3D40Dw8KgOaRkv1bYM/E=; b=W06BEghxSOW53peYtj1Z3RZridHQ2NHungQFPYY8estOj9if9HHQehKqzI5G165Hwe YPtDPYFOY747Q1egf/5KmHiGn+tVeUquzvjqGFLYjsUq/0uyAI9mPfBlNX+8o7ELXZt5 OHJWfSaiXMk/MQO4gafYgwx0QYFhjyKtR+YIvqT603iF2EFBR4xqG4V/cECFawpp6OeU iX6W2eTI6G33Z4zHJhuacKAOCGFgompvnDlCNaMOdUOxqW38/MUQBN+lB/1y6tOG1xzd jVfWqRy2pIklIHBchJu9gwi2zr0IJV6jy2N7VFHKFurk5oVoG4ycDB/xBXUm/GUMt0m9 7dtg== X-Gm-Message-State: AOJu0Yx40S293lIo500y8RSct5meE3cwgB96cvu3qEej3mOZbdmXjGK/ M/ssr34RIL55MvYC2XQsmoc4R1LQIpS8qq4QMQXUCgSGmeU4dIjlPtpQ/s7bXNH/BhwuWPvMP2m g+GpB0F1c6tn/7zMrkpK9+h1NAzP4A7VwsH3GIw== X-Gm-Gg: ASbGnctXLbK9i+SsdOgTXEzqj863sOHH1G2mgVN+doyRn0mFn7dCTLi90gMaBReGnob U/7VCcZURjWk7v4qIhxFcWVNoQc20HP3+wSspFewL527mHY/i7ah5NmG+SWbjNyaLWCvg7FwjGn SWWnsV0UDRLYZ2nbyXAW2m0cjFWdPT38k= X-Google-Smtp-Source: AGHT+IEJA5eO9cOUDaIbrlMDl8fHMRbsC9Usxhh2/gxoYIxaq5KtihJiONJOpwxYydDvIPBeMbMs5tjxc/5y2jmV4Bo= X-Received: by 2002:a7b:cc81:0:b0:448:d54a:ca23 with SMTP id 5b1f17b1804b1-450ce8376bamr40059895e9.8.1748590928580; Fri, 30 May 2025 00:42:08 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 30 May 2025 16:41:57 +0900 X-Gm-Features: AX0GCFvT8r-ZO_CEfjp-W53xnEuhEWa1C0HouCz-Pp1STYAcfxiLnuts4tRTrN0 Message-ID: Subject: Re: [PHP-DEV] Adding in a case-insensitive version of str_contains To: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: youkidearitai@gmail.com (youkidearitai) 2025=E5=B9=B45=E6=9C=8830=E6=97=A5(=E9=87=91) 16:20 Adam Cable : > > On Thu, May 29, 2025 at 10:00=E2=80=AFPM Kamil Tekiela wrote: >> >> As I understand, it was a conscious decision not to add this function >> when str_contains was created. The reason is that case sensitivity is >> locale-dependent, and for such use cases, mbstring extension is better >> [1] & [2]. Do you think that locale is a concern here, and if not, >> why? Would it be a good idea to add mb_str_icontains instead? >> >> If you're going to propose an RFC for this, it would be a good idea to >> explain what the real life use case for it is. While str_contains is >> very useful for checking the existence of a byte-string within another >> byte-string, a case-sensitive check doesn't seem to have much use. >> >> [1]: https://stackoverflow.com/a/63121809/1839439 >> [2]: https://wiki.php.net/rfc/str_contains#case-insensitivity_and_multi= byte_strings > > > Thanks for this. > > In terms of real-life cases, we deal with a lot of datafeeds and user-con= tributed content. > We have lots of rules engines that categorise or display data depending o= n the content contained (and sometimes these rules change from time to time= ). > So for example, we have a rule that if the string contains the word "excl= usive" that it's displayed in a certain way. > We can add a rule that says if (str_contains($text, "exclusive"))... and = if want to include the ability for sentences to start with the word "Exclus= ive" we currently have to write like this (as we like functions to be truth= y)... stripos(" ".$text, $exclusive) OR str_contains(strtolower($text), "e= xclusive") > > I'd just find it useful to have str_icontains/stri_contains available as = the same ASCII-folding variant that we have for other functions. Hi Surely, mbstring does not locale-dependency. And grapheme function also can not specify locale. (Default is no specify the locale) Perhaps, does grapheme function need to specify the locale? I thought so when I implemented the grapheme function. Regards Yuya --=20 --------------------------- Yuya Hamada (tekimen) - https://tekitoh-memdhoi.info - https://github.com/youkidearitai -----------------------------