Is there an off-the-shelf function to compute common string of string?

This is a discussion on Is there an off-the-shelf function to compute common string of string? within the C++ Programming forums, part of the General Programming Boards category; Say I have Str1="/home/root/1.txt.tmp1.test" Str2="/home/root/2.txt.tmp2.test" Str3="/home/root/3.txt.tmp3.test" Is there an off-the-shelf function to get the common string of the strings? In ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    284

    Is there an off-the-shelf function to compute common string of string?

    Say I have
    Str1="/home/root/1.txt.tmp1.test"
    Str2="/home/root/2.txt.tmp2.test"
    Str3="/home/root/3.txt.tmp3.test"

    Is there an off-the-shelf function to get the common string of the strings?
    In this case: common_str="/home/root/*.txt.tmp*.test"

  2. #2
    Registered User
    Join Date
    Apr 2007
    Posts
    284
    To be specific, what I want is "Longest common subsequence" of multiple strings

  3. #3
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,759
    Quote Originally Posted by meili100 View Post
    Say I have
    Str1="/home/root/1.txt.tmp1.test"
    Str2="/home/root/2.txt.tmp2.test"
    Str3="/home/root/3.txt.tmp3.test"

    Is there an off-the-shelf function to get the common string of the strings?
    In this case: common_str="/home/root/*.txt.tmp*.test"
    Actually, that is not the longest common substring at all. It's "/home/root/" - so you probably want to think in terms of a regular expression instead.

    Never the less, the problem you did mention has a pretty simple solution that you can write yourself.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Replies: 6
    Last Post: 04-21-2006, 09:49 PM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 01:56 PM
  5. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21