string.split() function
See original GitHub issue- Proposal (https://github.com/sass/sass/pull/3284)
- Tests (https://github.com/sass/sass-spec/pull/1841)
- Dart Sass (https://github.com/sass/dart-sass/pull/1839)
- Documentation
- Update canonical spec
It would be really useful to have a str-split($string, $delimiter:" ")
function akin to JavaScript, or Ruby.
The primary use case I run into is splitting selector strings i.e.
.foo .bar { /* code */ }
It’s rather difficult to get .bar
from &
without boilerplate string functions or importing something like sassdash.
A another use case I run into is remove part of selector. As it stands selector-replace
does not allow you to remove part of a selector (i.e. replace it with ""
or null
). Being able to easily split selector strings would makes this much easier.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:4
- Comments:15 (4 by maintainers)
Top Results From Across the Web
Python String split() Method - W3Schools
The split() method splits a string into a list. You can specify the separator, default separator is any whitespace. Note: When maxsplit is...
Read more >String.prototype.split() - JavaScript - MDN Web Docs
The split() method takes a pattern and divides a String into an ordered list of substrings by searching for the pattern, ...
Read more >Python String split() - Programiz
The split() method breaks up a string at the specified separator and returns a list of strings. Example. text = 'Python is a...
Read more >Split() String method in Java with examples - GeeksforGeeks
The string split() method breaks a given string around matches of the given regular expression. After splitting against the given regular ...
Read more >Java String split() method - Javatpoint
The java string split() method splits this string against given regular expression and returns a char array. Internal implementation. public String[] split( ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1 for a str-split or selector-split function
(Sorry, deleted my comment as it was redundant.)
Maybe a
selector-split
function would be more appropriate? Something that splits based on combinators: