SlickEdit Product Discussion > SlickEdit®

Function to check if SlickC string variable has a substring?

(1/1)

rowbearto:
Is there a SlickC function that returns if a SlickC string contains a particular substring?

For example lets say:


--- Code: ---_str fullString="hello world";
containsSubstring1 = some_match_function(fullString, "world");
if (containsSubstring1)
{
  // Should end up here because 'world' is in 'hello world'
}
else
{
  // Should not end up here because 'world' is in 'hello world'
}
containsSubstring2 = some_match_function(fullString, "abc123");
if (containsSubstring2)
{
  // Should NOT end up here because 'abc123' is not in 'hello world'
}
else
{
  // Should end up here because 'abc123' is not in 'hello world'
}
--- End code ---

rowbearto:
I think I found it, the pos() function?

Clark:
Yes, pos() does what you need

Clark:
I should mention that beginsWith() and endsWith() are also very handy for string matching.

Navigation

[0] Message Index

Go to full version