Skip to content

Comments

[FEAT] Added string helper functions#114

Merged
LukeTowers merged 12 commits intodevelopfrom
feat/str-helpers
Sep 21, 2022
Merged

[FEAT] Added string helper functions#114
LukeTowers merged 12 commits intodevelopfrom
feat/str-helpers

Conversation

@jaxwilko
Copy link
Member

This PR adds some string helper methods for common indexing operations.

  • index - adds the next index to a string
  • unique - adds the next index to a string calculated from a list of strings
  • uniqueFile - same as unique but working around the file extension to keep the index within the filename

Examples

'hello_world_1'       ===   Str::index('hello_world'));
'hello_world_2'       ===   Str::index('hello_world_1'));
'hello_world_43'      ===   Str::index('hello_world_42'));
'hello_world 3'       ===   Str::index('hello_world 2', separator: ' '));
'hello_world 6'       ===   Str::index('hello_world 2', separator: ' ', step: 4));
'hello_world8'        ===   Str::index('hello_world4', separator: '', step: 4));
'hello_world4_1'      ===   Str::index('hello_world4', step: 4));
'hello_world-22'      ===   Str::index('hello_world', separator: '-', starting: 22));
'winter cms 1'        ===   Str::index('winter cms', separator: ' '));
'winter cms 2'        ===   Str::index('winter cms 1', separator: ' '));

'winter_cms_4'        ===   Str::unique('winter_cms', ['winter_cms_1', 'test_5', 'winter_cms_3']));
'winter_cms 1'        ===   Str::unique('winter_cms', ['winter_cms_1', 'test_5', 'winter_cms_3'], ' '));
'winter_cms_1'        ===   Str::unique('winter_cms_1', ['winter_cms_1', 'test_5', 'winter_cms_3']));
'winter_cms_1'        ===   Str::unique('winter_cms', ['test_5']));

'winter_cms_4.test'   ===   Str::uniqueFile('winter_cms.test', ['winter_cms_1.test', 'test_5.egg', 'winter_cms_3.test']));
'winter_cms_1.test'   ===   Str::uniqueFile('winter_cms.test', ['test_5.test']));
'winter_cms_1.test'   ===   Str::uniqueFile('winter_cms_1.test', ['test_5.test']));

@LukeTowers LukeTowers added this to the 1.2.1 milestone Sep 21, 2022
@LukeTowers LukeTowers merged commit 5c46aa3 into develop Sep 21, 2022
@LukeTowers LukeTowers deleted the feat/str-helpers branch September 21, 2022 16:37
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