react-logviewer icon indicating copy to clipboard operation
react-logviewer copied to clipboard

Add Regex Search Support

Open ido123net opened this issue 1 year ago • 10 comments

Feature Request:

Please add regex search functionality to react-logviewer. This would enable more flexible and powerful search options, allowing users to match complex patterns in logs.

I'd be glad to help with a PR if needed! 😊 Keep in mind I'm new to the React world.

Thank you!

ido123net avatar Aug 29 '24 11:08 ido123net

PR would be great!

melloware avatar Aug 29 '24 11:08 melloware

OK @ido123net i can see why the original developer only did "Knuth–Morris–Pratt" string matching for search. Say you have a very large log file this string searching is way faster and more efficient than an expensive RegExp search.

melloware avatar Aug 29 '24 12:08 melloware

Yes, I also found it, I will try to leave the KMP part as is.

My idea is to implement a new function to search with regex, this will of-course be less efficient, therefore it will not be the default.

ido123net avatar Aug 29 '24 14:08 ido123net

I just committed some JS doc changes to document that class just so I know why it was doing it!

melloware avatar Aug 29 '24 14:08 melloware

@melloware look at #40 it works, but it breaks the highlights and filtering lines.

ido123net avatar Aug 29 '24 14:08 ido123net

I just committed some JS doc changes to document that class just so I know why it was doing it!

I saw, I pulled the latest 😉

ido123net avatar Aug 29 '24 14:08 ido123net

Yep I can point you to wheee the highlighting is happening and why it's not working. Let me review

melloware avatar Aug 29 '24 14:08 melloware

OK the bug is in here: https://github.com/melloware/react-logviewer/blob/3646bca8a1b8886ed2da8dacc42b9e83d49ba322/src/components/Utils/utils.ts#L135-L231

It does some magic tro remove regex strings and do a plain text match on highlighted words.

melloware avatar Aug 29 '24 15:08 melloware

Regular search takes too much time. Can we only implement only "or" and perform multiple KMP searches after splitting? For example: keyword1|keyword2|keyword3, I often use it filter logs by some tags.

yafacex avatar Jan 17 '25 07:01 yafacex

@yafacex feel free to help @ido123net with his PR!

melloware avatar Jan 17 '25 13:01 melloware