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

Fintune Regex for finding static content #7

Open
Lantzify opened this issue Oct 16, 2021 · 1 comment
Open

Fintune Regex for finding static content #7

Lantzify opened this issue Oct 16, 2021 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Lantzify
Copy link
Owner

The Regex for finding content still has some work to do. My solution works, but it feels a bit janky.

var staticContents = Regex.Matches(viewContent, @"(?<!(=>))(?<=>)(?![.,])([\s\w,.&?!'#\(]+)(.*?)")
                            .Cast<Match>()
                            .Where(x => !string.IsNullOrWhiteSpace(x.Value) && 
                                                 Regex.Match(x.Value, @"\D+").Length > 1 &&
                                                !Regex.IsMatch(x.Value, @"(if *\()"))
                             .Select(m => m.Value.Trim())
                             .ToList();

There are so many combinations on how static content is placed in views. Would like to come up a new solution to find static content that is a bit more robust and more fool proof.

In addition. It would be nice if it could:

  • Skip commented static content
@Lantzify Lantzify added enhancement New feature or request help wanted Extra attention is needed labels Oct 16, 2021
@Lantzify
Copy link
Owner Author

Maybe add a HTML parser to handle this instead of regex?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant