New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating regex tertiary methods #19622
Conversation
--- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
--- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
…d adding string.find and bytes.find which return byteIndex --- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
--- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
… argument to sep in split function --- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
--- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
--- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
--- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
--- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
…ex_tertiary --- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
…and bytes.startsWith --- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
--- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
--- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
--- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
--- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there's a mention of string.search on line 64 in the file that should be replaced with string.find.
Overall, I mostly was pointing out additional references and things to adjust. The changes themselves are otherwise pretty good, though there's one or two other things I had some suggestions on.
modules/standard/Regex.chpl
Outdated
proc string.search(pattern: regex(string), ref captures ...?k):regexMatch | ||
{ | ||
return pattern.search(this, (...captures)); | ||
} | ||
|
||
|
||
pragma "last resort" | ||
deprecated "the 'needle' argument is deprecated, use 'pattern' instead" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one also doesn't mention that there's a new name for the function.
modules/standard/Regex.chpl
Outdated
should be strings or types that strings can cast to. | ||
:returns: an :record:`regexMatch` object representing the offset in the | ||
receiving string where a match occurred | ||
:returns: true if string starts with :arg pattern:, false otherwise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:arg pattern:
is only useful at the start of a line, where it generates some formatting for it. I think what you meant is ":arg:pattern
" but I don't know that that will actually generate a link so it's probably best to surround pattern
with two backtics.
--- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
--- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
modules/standard/Regex.chpl
Outdated
@@ -1215,7 +1216,7 @@ proc string.search(needle: regex(string), ref captures ...?k):regexMatch | |||
/* Search the receiving string for a regular expression already compiled | |||
by calling :proc:`regex.search`. Search for matches at any offset. | |||
|
|||
.. warning:: the search function with a receiving string is deprecated | |||
.. warning:: the search function with a receiving string is deprecated, use regex search instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a little off, should it be on the following line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the minor formatting thing, looks good! Thanks!
--- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
--- Signed-off-by: slnguyen <26969019+slnguyen@users.noreply.github.com>
…ng#19622 Signed-off-by: Vassily Litvinov <vasslitvinov@users.noreply.github.com>
Remove some features deprecated ≥two releases ago Remove the following deprecated features, shown here with the date and PR of deprecation: * formals `needles`, `patterns` in string|bytes.find() et al. [2/24 #19222] * formal `dotnl` in regex.compile() [2/23 #17191] * method list.`indexOf`() [1/20 #19059] * class `BadRegexpError` [3/3 #19308] * fields regexMatch.`offset`,`size` [3/07 #19365] * string|bytes.`search`(),`split(pattern)` et al. [4/29 #19622] * channel.`match`() and some channel methods with `ref error` [3/23 #17448] * formal `i` in domain.contains() et al. [1/24 #19075] * operators `|` `&` `^` on rectangular domains [1/30 #19103] * methods domain.`isSuper`(),`isSubset`() [1/30 #19104] * functions `isRectangularDom`(), `isRectangularDom`() et al. [Oct'2021 #18534] Notes on removing channel.`match`() et al. * I retained this method and avoided deprecation warnings upon calling it: `proc _channel.search(re:regex(?)):regexMatch` For that, I converted a deprecated public method that it uses to a non-deprecated private one. * I moved `test/deprecated/regexp-rechan.chpl` back to `test/regex/ferguson/rechan.chpl` as it contains functionality not tested otherwise. For that, I converted calls to match() to calls to search() prepending "^" to the pattern they are matching for. This is what we expect users to do to adjust their codes. This changed the ending channel offset in some cases. I noted this in #20864. r: @lydia-duncan - thanks!
…ng#19622 Signed-off-by: Vassily Litvinov <vasslitvinov@users.noreply.github.com>
This PR addresses #17226 and does the following:
string.search
andbytes.search
(returns a regexMatch) with 'string.find' andbytes.find
, which returns a 'byteIndex' that represents the offset where a regular expression and string/byte matchbytes.matches
(returns a regexMatch) withstring.startsWith
andbytes.startsWith
, which returns true if a string/byte starts with a given regular expressionstring.matches
andbytes.matches
pattern
argument tosep
instring.split
andbytes.split