Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Expanded the README a bit.

  • Loading branch information...
commit c9840f298cc0e92c77b156a67168dbde043fc92d 1 parent f7560c9
@zacharyvoase authored
Showing with 27 additions and 0 deletions.
  1. +27 −0 README.rst
View
27 README.rst
@@ -49,6 +49,33 @@ All the methods on ``Scanner`` which take regexes will accept either regex
strings or compiled pattern objects (as would be returned from
``re.compile()``).
+``text_coords()``
+-----------------
+
+There's also a useful function provided, ``text_coords()``, which resolves
+simple string indices into textual co-ordinates (line number and column)::
+
+ >>> s = "abcdef\nghijkl\nmnopqr\nstuvwx\nyz"
+ >>> text_coords(s, 0)
+ (0, 0, 'abcdef')
+ >>> text_coords(s, 4)
+ (0, 4, 'abcdef')
+ >>> text_coords(s, 6)
+ (0, 6, 'abcdef')
+ >>> text_coords(s, 7)
+ (1, 0, 'ghijkl')
+ >>> text_coords(s, 11)
+ (1, 4, 'ghijkl')
+ >>> text_coords(s, 15)
+ (2, 1, 'mnopqr')
+
+Installation
+------------
+
+You can get the module from PyPI::
+
+ pip install strscan
+
(Un)license
===========
Please sign in to comment.
Something went wrong with that request. Please try again.