Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XRegExp opción 'x' no funciona #9

Closed
crguezl opened this issue Mar 18, 2016 · 0 comments
Closed

XRegExp opción 'x' no funciona #9

crguezl opened this issue Mar 18, 2016 · 0 comments
Assignees
Labels
Milestone

Comments

@crguezl
Copy link
Collaborator

crguezl commented Mar 18, 2016

Este es un ejemplo de prueba para testear la opción xde XRegExp:

{% regexp %}
¿Quienes reinaban en España cuando se descubrió America?
{% solution %}
Los Reyes Católicos
{% validation %}
/
  (Isabel\s+                    # nombre sencillo
  ((I\s+)?de\s+Castilla\s+)?    # titulo de Isabel
  y
  \s+Fernando                   # nombre sencillo
  (\s+(II\s+)?de\s+Arag[]n)?) # titulo de Fernando
|
  (Reyes\s+Cat[]licos)  # conocidos también por este nombre
/ix
{% endregexp %}

Para que funcione he cambiado las líneas de assets/myfile.js de construcción de la regexp por estas:

      var fail = $regexp.find(".fail");

      var match = codeValidation.match(/^\/((?:.|\n)*)\/([sxnAgimy]*)$/);
      var pattern = match[1]; 
      var flags = match[2];
      var regex = XRegExp(pattern,flags);

Estas líneas sustituyen a las que ahora están:

       var fail = $regexp.find(".fail");
-      var regexp = new RegExp(codeValidation, "i");
+
+      var flags = codeValidation.replace(/.*\/([gimy]*)$/, '$1');
+      var pattern = codeValidation.replace(new RegExp('^/(.*?)/'+flags+'$'), '$1');
       var regex = XRegExp(pattern,flags);
@crguezl crguezl added the bug label Mar 18, 2016
@crguezl crguezl added this to the operativa milestone Mar 18, 2016
@crguezl crguezl changed the title XRegExpopción x no funciona XRegExp opción 'x' no funciona Mar 18, 2016
@crguezl crguezl closed this as completed Mar 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants