regex problem for comments line

Discussion in 'Ruby' started by Ahmet Kilic, Sep 28, 2009.

  1. Ahmet Kilic

    Ahmet Kilic Guest

    str = " uses
    Windows, Messages, SysUtils, Classes, Controls, Forms, Dialogs,
    Graphics,
    Login_c, Login_i,
    Utility_c, Utility_i,
    Agent_i,
    MMenu, // メニューオブジェクト
    CtrlForm, // ç”»é¢èµ·å‹•åˆ¶å¾¡
    CommonData, // 共有データä¿æŒã‚¯ãƒ©ã‚¹
    ServerAccess, // 通信ラッピング層統括クラス
    MasterList, // å称マスター管ç†ã‚¯ãƒ©ã‚¹
    IniFileAccess, // iniファイル管ç†ã‚¯ãƒ©ã‚¹
    MessageAccess, // 共通メッセージ管ç†ã‚¯ãƒ©ã‚¹
    LogAccess, // ログ出力制御クラス
    TelephoneCommand, // 電話制御用コマンドクラス
    TelephoneDataClass, // 電話制御用データクラス
    ExtCtrls, jpeg, StdCtrls;

    type "

    str.scan(/^\s*uses\s*$(.*?)\s*,\s*(\S+)\s*;\s*^type/m) do |us|
    names = $1
    names.split(/,/).each do |name| # split the words(w+) only
    sub_name = names.gsub(/\/*\s*(\S+)$/, "") # problem here
    I think
    puts " ===== sub names ======= #{ sub_name}"
    # puts " >>>>>>> here uses #{ name}"
    if /(\w+)/m =~ name
    ref = $1
    var = $1
    # puts "@@@@@@@ here uses #{ var}"
    if class_name
    # puts " class name : #{class_name} reference class
    name #{var} "
    end
    end
    end
    end

    please help me abut this problem. I want to exclude or split the
    comments.( japanese comment parts). I tried many combinations but still
    problem.
     
    Ahmet Kilic, Sep 28, 2009
    #1
    1. Advertisements

  2. Ahmet Kilic

    Ahmet Kilic Guest

    not working,

    also this is not working \/*\s*(\w+)$
     
    Ahmet Kilic, Sep 28, 2009
    #2
    1. Advertisements

  3. irb> puts t
    str =3D " uses
    Windows, Messages, SysUtils, Classes, Controls, Forms, Dialogs,
    Graphics,
    Login_c, Login_i,
    Utility_c, Utility_i,
    Agent_i,
    MMenu, // =E3=83=A1=E3=83=8B=E3=83=A5=E3=83=
    =BC=E3=82=AA=E3=83=96=E3=82=B8=E3=82=A7=E3=82=AF=E3=83=88
    CtrlForm, // =E7=94=BB=E9=9D=A2=E8=B5=B7=E5=8B=95=
    =E5=88=B6=E5=BE=A1
    CommonData, // =E5=85=B1=E6=9C=89=E3=83=87=E3=83=BC=
    =E3=82=BF=E4=BF=9D=E6=8C=81=E3=82=AF=E3=83=A9=E3=82=B9
    ServerAccess, // =E9=80=9A=E4=BF=A1=E3=83=A9=E3=83=83=
    =E3=83=94=E3=83=B3=E3=82=B0=E5=B1=A4=E7=B5=B1=E6=8B=AC=20
    =E3=82=AF=E3=83=A9=E3=82=B9
    MasterList, // =E5=90=8D=E7=A7=B0=E3=83=9E=E3=82=B9=
    =E3=82=BF=E3=83=BC=E7=AE=A1=E7=90=86=E3=82=AF=E3=83=A9=20
    =E3=82=B9
    IniFileAccess, // ini=E3=83=95=E3=82=A1=E3=82=A4=E3=83=
    =AB=E7=AE=A1=E7=90=86=E3=82=AF=E3=83=A9=E3=82=B9
    MessageAccess, // =E5=85=B1=E9=80=9A=E3=83=A1=E3=83=83=
    =E3=82=BB=E3=83=BC=E3=82=B8=E7=AE=A1=E7=90=86=E3=82=AF=20
    =E3=83=A9=E3=82=B9
    LogAccess, // =E3=83=AD=E3=82=B0=E5=87=BA=E5=8A=9B=
    =E5=88=B6=E5=BE=A1=E3=82=AF=E3=83=A9=E3=82=B9
    TelephoneCommand, // =E9=9B=BB=E8=A9=B1=E5=88=B6=E5=BE=A1=
    =E7=94=A8=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89=E3=82=AF=20
    =E3=83=A9=E3=82=B9
    TelephoneDataClass, // =E9=9B=BB=E8=A9=B1=E5=88=B6=E5=BE=A1=
    =E7=94=A8=E3=83=87=E3=83=BC=E3=82=BF=E3=82=AF=E3=83=A9=20
    =E3=82=B9
    ExtCtrls, jpeg, StdCtrls;

    type "
    =3D> nil

    irb> puts t.gsub(%r{\s*//.*$},'')
    str =3D " uses
    Windows, Messages, SysUtils, Classes, Controls, Forms, Dialogs,
    Graphics,
    Login_c, Login_i,
    Utility_c, Utility_i,
    Agent_i,
    MMenu,
    CtrlForm,
    CommonData,
    ServerAccess,
    MasterList,
    IniFileAccess,
    MessageAccess,
    LogAccess,
    TelephoneCommand,
    TelephoneDataClass,
    ExtCtrls, jpeg, StdCtrls;

    type "
    =3D> nil


    Rob Biedenharn http://agileconsultingllc.com
     
    Rob Biedenharn, Sep 28, 2009
    #3
  4. Ahmet Kilic

    Ahmet Kilic Guest

    thank you very much.
     
    Ahmet Kilic, Sep 28, 2009
    #4
  5. Ahmet Kilic

    whjtsppes

    Joined:
    Apr 12, 2012
    Messages:
    1
    Likes Received:
    0
    thanks for your share

    thanks your for sharing
     
    whjtsppes, Apr 12, 2012
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.