Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > regex problem for comments line

Reply
Thread Tools

regex problem for comments line

 
 
Ahmet Kilic
Guest
Posts: n/a
 
      09-28-2009
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.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Ahmet Kilic
Guest
Posts: n/a
 
      09-28-2009
Ehsanul Hoque wrote:
>> MasterList, // 名称マスター管理クラス
>> IniFileAccess, // iniファイル管理クラス
>> MessageAccess, // 共通メッセージ管理クラス
>> LogAccess, // *グ出力制御クラス
>> TelephoneCommand, // 電話制御用コマンドクラス
>> TelephoneDataClass, // 電話制御用データクラス
>> ExtCtrls, jpeg, StdCtrls;
>>
>> type "

>
>> please help me abut this problem. I want to exclude or split the
>> comments.( japanese comment parts). I tried many combinations but still
>> problem.

>
>
> How about this:
>
> str.gsub!(/\/\/.*/, "")


not working,

also this is not working \/*\s*(\w+)$
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Rob Biedenharn
Guest
Posts: n/a
 
      09-28-2009

On Sep 28, 2009, at 4:11 AM, Ahmet Kilic wrote:

> Ehsanul Hoque wrote:
>>> 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=2 0
>>> =E3=83=A9=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=20
>>> =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=2 0
>>> =E3=82=AF=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=2 0
>>> =E3=82=AF=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=2 0
>>> =E3=83=A9=E3=82=B9
>>> ExtCtrls, jpeg, StdCtrls;
>>>
>>> type "

>>
>>> please help me abut this problem. I want to exclude or split the
>>> comments.( japanese comment parts). I tried many combinations but =20=


>>> still
>>> problem.

>>
>>
>> How about this:
>>
>> str.gsub!(/\/\/.*/, "")

>
> not working,
>
> also this is not working \/*\s*(\w+)$
> --=20


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=E 3=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=8 2=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=8 B=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=8 3=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=8 2=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=8 2=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=8 3=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
http://www.velocityreviews.com/forums/(E-Mail Removed)


 
Reply With Quote
 
Ahmet Kilic
Guest
Posts: n/a
 
      09-28-2009
thank you very much.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
whjtsppes whjtsppes is offline
Junior Member
Join Date: Apr 2012
Posts: 1
 
      04-12-2012
thanks your for sharing
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How make regex that means "contains regex#1 but NOT regex#2" ?? seberino@spawar.navy.mil Python 3 07-01-2008 03:06 PM
A program to replace all JS comments with JSP comments in jsp files tungchau81@yahoo.com Java 0 06-02-2006 06:35 AM
regex bug (comments within regex not as robust) kg.google@olympiakos.com Perl Misc 3 10-27-2005 07:21 PM
Comments format: comments extending over multi-line Monk C Programming 10 04-20-2005 05:09 PM
Right regex to match -- comments or blank line? Dave Sisk Perl 3 03-05-2004 08:35 PM



Advertisments