Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using regexxer to translate an application that use .php files. In accordance to the webpage it's based on usage and syntax of Perl regular expressions. It looks more to be applied to Perl code. I'm not experienced in regex and the most "complex" things I've achieved are:

Search: 'Name must be between (\d+) and (\d+) characters!'
Replace: '¡Nombre debe tener entre $1 y $2 caracteres!'

and:

Search: 'Password(:|')
Replace: 'Contraseña$1

With +200 files and 5/50 lines/vars each one I can save hours/days with less and more complex regex. How can I do this?:

Search: '(any word) must be between (\d+) and (\d+) (other word)!'
Replace: '¡$1 debe tener entre $2 y $3 $4!'

and this? (find any string that begins with 'Warning: ' and ends with '!' in order to replace 'Warning: ' with 'Advertencia: ¡'):

Search: 'Warning: File not found!'
Replace: 'Advertencia: ¡Archivo no encontrado!'

Please help me what to type into regexxer.

share|improve this question
1  
regex coach is a nice free program for testing regexes. jgsoft make some regex related tools that aren't free. –  barlop Dec 24 '12 at 17:35
add comment

1 Answer

up vote 1 down vote accepted

This regex matches between two strings

(?<=first).*?(?=last)

e.g. it matches for this text, between first and last. firstfgdfgfddlast

tested in http://gskinner.com/RegExr/ (took me a while to find an online regex tester that worked! I guess many don't support lookbehind. But that one is good).

Improvement added by quantme-
In regexxer:

Search: 'Warning: (.*?)!'
Replace: 'Advertencia: ¡$1!'
share|improve this answer
    
It works exactly as I need! And the online regex tester is great! –  quantme Dec 24 '12 at 17:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.