rimuovi la stringa che contiene il numero dal testoCIAO,
Esiste un modo per rimuovere qualsiasi stringa contenente numeri utilizzando JSL?
Esempio:
Ho mangiato 4 mele e 2 banane
il numero del modello è 0998GBELS
03/45 è il rapporto da controllare
Output mirato:
Ho mangiato mele e banane
il numero del modello è
è il rapporto da controllare
Automazione e scriptingRe: rimuovi la stringa che contiene il numero dal testoNon sono sicuro che funzionerebbe in tutte le situazioni, ma funziona per questi esempi
Names Default To Here(1);
strs = {
"I ate 4 apples and 2 bananas",
"the model number is 0998GBELS",
"03/45 is the ratio to check"
};
result2 = Transform Each({str}, strs,
Regex(str, "\w*\S*\d+\w*\S*", "", GLOBALREPLACE)
);
show(result2); // result2 = {"I ate apples and bananas", "the model number is ", " is the ratio to check"};
Modificare:
Penso che regex possa essere semplificato un po' per
Regex(str, "\S*\d+\S*", "", GLOBALREPLACE)
https://regex101.com/r/PM4UQn/1
Re: rimuovi la stringa che contiene il numero dal testoHo molte linee da elaborare (centinaia di milioni), quindi farlo causerà una latenza più elevata. Mi chiedo se esista un modo migliore per rimuovere quelle stringhe che contengono numeri con latenza più bassa?
Re: rimuovi la stringa che contiene il numero dal testoFunziona, ma qualcuno che ha familiarità con le espressioni regolari potrebbe semplificare lo script
Names Default To Here( 1 );
theString = "I ate 4 apples and 2 bananas
the model number is 0998GBELS
03/45 is the ratio to check";
theList = Words( theString, " \!n\!r\!t" );
adjustedString = "";
For Each( {member}, theList,
Show( member );
//member=thelist[1]
found = "No";
If( !Contains( member, "0" ),
If( !Contains( member, "1" ),
If( !Contains( member, "2" ),
If( !Contains( member, "3" ),
If( !Contains( member, "4" ),
If( !Contains( member, "5" ),
If( !Contains( member, "6" ),
If( !Contains( member, "7" ),
If( !Contains( member, "8" ),
If( !Contains( member, "9" ),
adjustedString = Trim( adjustedString || " " || member )
)
)
)
)
)
)
)
)
)
);
);
Show( adjusted String );