file A useful search script

6 years 5 months ago - 6 years 5 months ago #446 by pan
Hi,

In Modelio, there is a fast search feature which allows to search for namespaces however it misses a functionality that allows to search for a largest scope of objects.
This is a Jython script that allows to search for more elements (attributes, operations, ...).

How to use it:
1 - Enter the word you are looking for (it accepts regular expression)
2 - Select the metaclasses by which you are interested (Use IModelElement to search for all elements)
3 - Click Search button

See the attached screenshot for an example.
In this example, we search for an attribute starting with "tot" so we use a regular expression "tot.*" to find it. We select the metaclass "IAttribute" then we click on Search button. We found 2 attributes starting with "tot".
For objects containing "tot", we will use the expression ".*tot.*"





Hope this helps.


File Attachment:

File Name: searchElement.zip
File Size:3 KB
Attachments:
The following user(s) said Thank You: andy

Please Log in or Create an account to join the conversation.

6 years 2 months ago #795 by pan
This script has been updated.
Check the latest version of the Advanced Search Jython script

What's new?
- Regular expression search option added
- Catching exception if regular exception is incorrect
- IModelElement metaclass selected by default. IModelElement is one of the top metaclass element so it is now selected by default.

Please Log in or Create an account to join the conversation.

6 years 3 weeks ago #940 by pan
Regular expressions are powerful but they are not always simple and intuitive to uses so we will learn to use them efficiently with some examples.

Here is some regular expressions:

How to find elements containing a digit string

Use "(.*)(\d)(.*)" or "(.*)[0-9](.*)"
Regular expressions used:
\d: matches digits (equivalent to [0-9])
.: matches any single character

Search for an element starting by the letter i (case-insensitive)

Use "^(?i)I(.*)"
Regular expressions used:
^: matches beginning of line.
(?i): makes pattern case-insensitive (by default the search pattern is case-sensitive)


More information about the regular expressions:
- Regular Expressions and the Java Programming Language

Regularly, we will update this post with more examples.

Please Log in or Create an account to join the conversation.

Moderators: chmcma
Time to create page: 0.176 seconds
^ Back to Top