Skip to content

Why does Regex::new report an error when reading the pattern from a file, but not when using a string literal? #1245

Answered by BurntSushi
kirs112 asked this question in Q&A
Discussion options

You must be logged in to vote

Your reproduction instructions were insufficient. Firstly, your program wouldn't compile. Here is an updated program that does:

use regex::Regex;

fn main() {
    let date:String = "\u{5}\0\r\u{3}\u{10}\0\0\0\u{18}\0\0\0\0\u{8}\u{1}@\u{4}\0\u{1}\u{5}\0\0\0\0".parse().unwrap();

    let mut matten: Vec<String> = Vec::new();
    let nsp_str = include_str!("./nmap-service-probes.txt");
    let mut nsp_lines = Vec::new();
    for l in nsp_str.lines() {
        nsp_lines.push(l.to_string());
    }

    for line in nsp_lines {
        if line.contains("#") {
            continue;
        } else if line.contains("Exclude") {
            continue;
        }
        if line.starts_with("match") {

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kirs112
Comment options

Answer selected by BurntSushi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1244 on November 30, 2024 19:50.