Skip to content

[9.x] Added betweenFirst to Stringable - #41144

Merged
taylorotwell merged 1 commit into
laravel:9.xfrom
yoeriboven:betweenFirst
Feb 21, 2022
Merged

[9.x] Added betweenFirst to Stringable#41144
taylorotwell merged 1 commit into
laravel:9.xfrom
yoeriboven:betweenFirst

Conversation

@yoeriboven

Copy link
Copy Markdown
Contributor

I was getting unexpected results with the between method.

Str::between('[1] bla bla [2]', '[', ']');

// Expected: '1'
// Actual: '1] bla bla [2'

Looking at the tests this is actually the expected result and changing it would result in a breaking change.

I added the betweenFirst method to get the result I expected.

Str::betweenFirst('[1] bla bla [2]', '[', ']');

// '1'

between PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants