question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

string.split() function

See original GitHub issue

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:open
  • Created 8 years ago
  • Reactions:4
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
esr360commented, Nov 14, 2016

+1 for a str-split or selector-split function

1reaction
davidkpianocommented, Jan 5, 2016

(Sorry, deleted my comment as it was redundant.)

Maybe a selector-split function would be more appropriate? Something that splits based on combinators:

$test: selector-split(".foo .bar", " ");
// => ((.foo,), (.bar,))

$test: selector-split(".foo .bar > .baz", ">");
// => ((.foo, .bar), (.baz,))
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found