I was trying with regular expressions to add single quotes to a word, taking care if in the expression I have single, doubles or none quotes. I have this
find . -type f -print0 | xargs -0 sed -i "s/{% url \([^\' >][^\" >][^ >]*\)/{% url \'\1\'/g"
Example
{% url something foo bar %}
{% url "something" foo bar %}
{% url 'something' foo bar %}
should be replaced by
{% url 'something' foo bar %}
But in case
{% url "something.else" foo bar %}
it changes to
{% url '"something.else"' foo bar %}
Single quotes can't be escaped in single qoutes, and the same with doubles/doubles isn't it? How do I do? Regular expressions are fantastic but dificults too. Thanks!!
The origin was problems with urls in Django 1.5
"Django release 1.5: 'url' requires a non-empty first argument. The syntax changed in Django 1.5"
I found an answer to change to double quotes here.
But same problem occurs with single quotes, replace 'word' to "'word'".