Project

General

Profile

Actions

Feature #12964

closed

Add sub? and gsub? method to string class.

Added by LTheGreats (Lachlan Wilger) about 8 years ago. Updated about 8 years ago.

Status:
Feedback
Assignee:
-
Target version:
-
[ruby-core:78238]

Description

The sub? and gsub? method would allow you to check if you can sub or gsub the string.

Updated by shyouhei (Shyouhei Urabe) about 8 years ago

  • Status changed from Open to Feedback

Sorry, I feel difficulty understanding your request. What is wrong with normal regexp matches? Be a bit more descriptive about what is wanted.

Updated by herwinw (Herwin Quarantainenet) about 8 years ago

I don't really see how this would be any different from match?

Beside that, the semantics are a bit ambiguous. "foo".sub(/bar/, 'x') does work, it just doesn't replace anything because there is no match for the regex. So would sub? mean that we can replace it at least once, and gsub? that we can replace it at least twice?

Actions

Also available in: Atom PDF

Like0
Like0Like0