Regex to fetch a line by the matching the last word , but the lastword should not be selected -


i need regular expression needs fetch line has 1 matching word @ end. should select line without selecting lastword.

for e.g

abc = new obj(); //object object_creation

regex should select above statement has object_creation @ end should select upto below one. object_creation keyword should used identify line , should not selected.

expected output

abc = new obj(); //object

is possible that?

just replace last word along preceding space character empty string.

string.replaceall("\\s*\\s+$", ""); 

or

string.replaceall("\\s*\\s+\\s*$", ""); 

or

matche chars upto last space.

pattern p = pattern.compile(".*(?= )"); 

or

pattern p = pattern.compile(".*(?=\\s)"); 

Comments

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Using jquery append to add option values into a select element not working -

javascript - Restarting Supervisor and effect on FlaskSocketIO -