groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <blackd...@gmx.org>
Subject Re: More Default String Methods
Date Sun, 14 Oct 2018 09:04:58 GMT
On 12.10.2018 21:22, adithyank wrote:
> As suggested by Jochen Theodorou in this
> link
> <http://groovy.329449.n5.nabble.com/New-DSLs-in-the-groovy-platform-itself-for-more-script-like-use-cases-td5750522.html>
> post, I have created this topic for `More Default String Methods`
> 
> I would like to work in these if the community accepts this proposal
> 
> //Method to return left n characters
> *1. static String left(String self, int chars)*

self[0..chars]?

> //Method to return right n characters
> *2. static String right(String self, int chars)*

self[-chars..-1]?

> //Method to return the String that is after the first occurrence of the
> given searchString
> *3. static String after(String self, String searchString)*
> 
> //Method to return the String that is before the first occurrence of the
> given searchString
> *4. static String before(String self, String searchString)*

these sound more interesting... empty String if the search string is not 
in self?

> //Method to return the String that is before the first '=' character
> *5. static String getBeforeEq(String self)*

which is foo.before("=") if number 4 is taken... This method looks to me 
a bit overspecialized

> /**
> Splits the given String with the given separator String and returns the
> value at the given column Index. By
> default, successive occurrence of the separator String is taken are one unit
> and the split is performed
> */
> *6. static String column(String self, String separator, int colIndex)*
>
> /**
> Splits the given String with Space characters and returns the value at the
> given column Index.
> */
> *7. static String column(String self, int colIndex)*

self.split(speparator)[colIndex]?

> //Method to return the String that is between the pair of double quotes
> *8. static String bwDoubleQuotes(String line)*
> 
> //Method to return the String that is between the pair of single quotes
> *9. static String bwSingleQuotes(String line)*

again these look a bit overspecialized to me

> //Method to return the String that is between the pair of given enclosure
> String
> *10. static String bw(String line, String enclosure)*
> 
> //Method to return the String that is between the 2 given strings
> *11. static String bw(String line, String from, String to)*
> 
> 
> //Method to return the String that is between the nth pair of double quotes
> *12. static String bwDoubleQuotes(String line, int index)*
> 
> 
> //Method to return the String that is between the nth pair of single quotes
> *13. static String bwSingleQuotes(String line, int index)*

so 10 is 11 with from=to, 12 is 10 if enclosure " and 13 is 10 with 
enclosure '. so don`t know about 12 and 13

> //Method to return the String that is between the nth pair of given
> enclosure String
> *14. static String bw(String line, String enclosure, int index)*

this could be interesting to have

> //Method to check whether searchString exists within self String ignoring
> the case
> *15. static boolean containsIgnoreCase(String self, String searchString)*
> 
> //Method to check whether the String starts with the searchString ignoring
> the case
> *16. static boolean startsWithIgnoreCase(String self, String searchString)*
> 
> //Method to check whether the String ends with the searchString ignoring the
> case
> *17. static boolean endsWithIgnoreCase(String self, String searchString)*

these could be interesting because they are actually not so easy to get 
right and efficient in a unicode world

bye Jochen

Mime
View raw message