Re: [VOTE] Voting opens for str_starts_with and ends_with functions
| From: | Christoph M. Becker | Date: | Mon, 08 Jul 2019 13:20:48 +0000 |
| Subject: | Re: [VOTE] Voting opens for str_starts_with and ends_with functions | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-106170@lists.php.net to get a copy of this message | ||
On 08.07.2019 at 15:05, Andrew Gromov wrote:
>> Please don't switch behaviours via flags: separate names and
>> implementations are much clearer and much simpler to follow.
>>
>> Yes, you will have multiple variations, but that's fine.
>
>
> It is depends of preferences.
>
> In my opinion, create new function for every possible situation is more
> worse
> then use flags.
>
>
>
> Python
>
>
> str.startswith(prefix[, start[, end]]) -> bool
>
>
>
> C#
>
>
> public bool StartsWith (string value, bool ignoreCase,
> System.Globalization.CultureInfo culture);
>
>
> public bool StartsWith (string value, StringComparison comparisonType);
>
>
>
> JS
>
>
> str.startsWith(searchString[, position])
>
>
>
> Kotlin
>
>
> fun String.startsWith(prefix: String, startIndex: Int = 0, ignoreCase:
> Boolean =
> false): Boolean
>
>
>
> R
>
>
> startsWith(str, pattern, trim=FALSE, ignore.case=FALSE)
>
>
>
> Scala
>
>
> startsWith[B](that: GenSeq[B], offset: Int): Boolean
>
>
> Golang, java, C++, Ruby, Swift have simples syntax, like
> string.startsWith(prefix)
>
>
>
> C#, Kotlin, R uses flag for ignore case.
>
>
> Anyway, I can't find language from various TOP-lists where present separate
> function for case insensitive operations.
>
>
> Another note - I see that many languages provide “start_index” parameter
> for
> start_with functions.
>
>
> So… As I say - this is good rfc in perspective, but more discussion is
> needed.
FTR, there is already substr_compare().
Thanks,
Christoph