ruby on rails - How can I cut only necessary part of string in RoR? -


for exsmple:

i have: new.string-@22/4576/:thisneedtoo.ffgfhha.pdf?7765trimsaskellyo2212

and need only: string-@22/4576/:thisneedtoo.ffgfhha.pdf?

if string starts "new.", , want after , including question mark, simple ruby regular expression pull out:

match_data = /\anew\.([^?]+\?).+\z/.match(s) match_data[1]  => "string-@22/4576/:thisneedtoo.ffgfhha.pdf?" 

i start easy-to-understand regular expression , once working, refine , optimize expression , add error checking.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -