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

RexExp Delimiter with Ignore Case Flag and Multiple Matches of Differing Case Causes Offset in First Instance #26

Open
saviourofdp opened this issue May 10, 2016 · 0 comments

Comments

@saviourofdp
Copy link

for working example, see http://codepen.io/anon/pen/pyYJzv

If you have

<div>
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do. Eiusmod tempor incididunt ut labore et dolore magna aliqu.
  Lorem IPSUM dolor sit amet, consectetur adipisicing elit, sed do. Eiusmod tempor incididunt ut labore et dolore magna aliqu.
</div>

and search for ipsum

$("div").blast({ delimiter: /ipsum/gi, debug:true });

notice the case of ipsum in both sentences. The result is

<div aria-label="..." class="blast-root">
  Lorem<span class="blast" aria-hidden="true" style="background-color: rgb(7, 93, 154);"> ipsu</span>m dolor sit amet, consectetur adipisicing elit, sed do. Eiusmod tempor incididunt ut labore et dolore magna aliqu.
  Lorem <span class="blast" aria-hidden="true" style="background-color: rgb(241, 33, 133);">IPSUM</span> dolor sit amet, consectetur adipisicing elit, sed do. Eiusmod tempor incididunt ut labore et dolore magna aliqu.
</div>

notice that the first instance is offset by 1

<span ...> ipsu</span>m

My workaround is to lower-case the comparison of matchText and subMatchText, although I don't think this is the correct solution as simple lowercase comparisons are not necessarily appropriate in all locales:

https://github.com/saviourofdp/blast/commit/1a171d62c3af3fa2e980cebe76e1cd9a39e7dbc8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant