Skip to content

[HELP] Get Line Number using the content of a Line as input #1248

Discussion options

You must be logged in to vote

Messing around in one of my random list files and using tp directly i found this works to output the current file line number of a given text:
<% tp.file.content.split("\n").indexOf("<search_text_here>") %>

I would imagine this would need to be expanded upon for larger file sizes, but in a pinch and shorter file lengths this is probably fine.

note: .indexOf() returns 0 on the first element, so you'd need to add one if that matters

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@FelipeRearden
Comment options

@steven-serka
Comment options

Answer selected by FelipeRearden
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants