Gsub and reg expressions


#1

After considerable time racking my brains on this one I am unsure on
where to go.

I am trying to replace some text with a the string ‘local’

I am reading some data from an event description, therefore using a
regular expression to get only the data i want which is ‘Logon Type: 2’

This works fine but when I add gsub to the expression in an attempt to
replace ‘Logon Type: 2’ with “local” I get the following error:

C:/Documents and Settings/sc/Desktop/stutest.rb:116:in `gsub’: wrong
argumen
t type Array (expected Regexp) (TypeError)

Also my code

#{event.description.gsub([/Logon Type:\t2/], ‘Local’)}")

Thanks in advance


#2

Stuart C. wrote:

After considerable time racking my brains on this one I am unsure on
where to go.

I am trying to replace some text with a the string ‘local’

I am reading some data from an event description, therefore using a
regular expression to get only the data i want which is ‘Logon Type: 2’

This works fine but when I add gsub to the expression in an attempt to
replace ‘Logon Type: 2’ with “local” I get the following error:

C:/Documents and Settings/sc/Desktop/stutest.rb:116:in `gsub’: wrong
argumen
t type Array (expected Regexp) (TypeError)

Also my code

#{event.description.gsub([/Logon Type:\t2/], ‘Local’)}")

mmm

[/Logon Type:\t2/] IS an Array

/Logon Type:\t2/ is a Regexp

take off the square brackets :wink:
and you have:

("#{event.description.gsub(/Logon Type:\t2/, ‘Local’)}")

Thanks in advance

Not at all

Duilio R.