Getting common value between two different string in Java -


i have 2 strings, , have same value between strings
here how is:

string temppath = "teb-mri-sud-krt-thb-du-psg-boi-rw"; string lewat = "dp-dpb-poc-ui-up-lna-tnt-psm-drn-cw-teb-mri-sud-krt-thb-du-kpb"; 

i want common value between 2 strings , make string variable this

string passedpath = "teb-mri-sud-krt-thb-du-"; 

variable passedpath same value of 2 string, later used subtract temppath can new, unvisited path this

temppath = temppath.replace(passedpath,""); // temppath valued "psg-boi-rw" 


so question is, how passedpath value 2 strings? i've tried searching case in stackoverflow directed string comparation questions.

can me try achieve this? or direct me question same case mine? thank :)

*ps: values in strings (teb,mri,sud etc) ordered is, there 1 occurence if there occurence of same substring in temppath , lewat

seems need implement algorithm solving the
"longest common substring" problem.

see here, there's plenty of information: http://en.wikipedia.org/wiki/longest_common_substring_problem
also, google "longest common substring".

the simplest solution dynamic programming approach.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -