module CommonRegularExpressions
REGULAR_EXPRESSION_1 = /one/
REGULAR_EXPRESSION_2 = /two/
end
class OverHere
def call_me(input)
return input[CommonRegularExpressions.REGULAR_EXPRESSION_1]
end
end
class WithInclude
include CommonRegularExpressions
def call_me_too(input)
return input.scan(REGULAR_EXPRESSION_2)
end
end
rails - how to make module for common regular expressions [closed]
-
18-07-2023 - |
Question
i use about 3 - 4 common Reqular Expressions inside most of models. so i want to put these regular expressions in module to use them directly instead of repeating it in every model. how can i accomplish that?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow