re = /NSLocalizedString\((.*)\s*,\s*(.*)\)/m
str = '// With text and comment
NSLocalizedString(@"Example Text", @"Example Comment");
// With text and no comment
NSLocalizedString(@"Example, text", nil)
// With text and comment with paranthesis
NSLocalizedString(@"Example text", @"Example (with paranthesis) comment")
// With property and no comment
NSLocalizedString(test, nil)
// With property and comment
NSLocalizedString(test, @"Example comment")
// Inline
NSLocalizedString(@"Error", nil) NSLocalizedString(@"Change settings", @"Option to change HTTP Post settings") NSLocalizedString(@"Cancel", nil)'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html