Welcome, Guest
Username Password: Remember me

A useful search script
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: A useful search script

A useful search script 1 year, 3 months ago #446

  • pan
  • OFFLINE
  • Moderator
  • Posts: 148
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.*"

search_example.png


search_example2.png


Hope this helps.


File Attachment:

File Name: searchElement.zip
File Size: 3 KB
Last Edit: 1 year, 3 months ago by pan.
The following user(s) said Thank You: andy

Re: A useful search script 1 year, 1 month ago #795

  • pan
  • OFFLINE
  • Moderator
  • Posts: 148
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.

Re: A useful search script 11 months ago #940

  • pan
  • OFFLINE
  • Moderator
  • Posts: 148
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.
  • Page:
  • 1
Moderators: chm, cma
Time to create page: 0.19 seconds