Skip to content

builtin: add string.split_by_space()#23651

Merged
spytheman merged 1 commit into
vlang:masterfrom
gechandesu:string_split_by_space
Feb 4, 2025
Merged

builtin: add string.split_by_space()#23651
spytheman merged 1 commit into
vlang:masterfrom
gechandesu:string_split_by_space

Conversation

@gechandesu

@gechandesu gechandesu commented Feb 4, 2025

Copy link
Copy Markdown
Contributor

This PR:

  • Add new fn split_by_space() for string builtin.
  • Add test

Usecase:

>>> cmd := os.execute('ip -br link show wlan0')
>>> cmd.output
wlan0            UP             14:75:7b:ca:a2:c4 <BROADCAST,MULTICAST,UP,LOWER_UP> 
>>> cmd.output.split_by_space()
['wlan0', 'UP', '14:75:7b:ca:a2:c4', '<BROADCAST,MULTICAST,UP,LOWER_UP>']
>>> mac := cmd.output.split_by_space()[2]
>>> mac
14:75:7b:ca:a2:c4

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-22072

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman spytheman merged commit 4f85b35 into vlang:master Feb 4, 2025
@gechandesu gechandesu deleted the string_split_by_space branch April 11, 2025 12:44
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