# getFirstNodeByName() returns None when '(' or ')' is in the name

**URL:** <https://discourse.slicer.org/t/getfirstnodebyname-returns-none-when-or-is-in-the-name/22437>\
**Category:** Support\
**Created:** [March 10, 2022, 4:40pm UTC](https://discourse.slicer.org/t/getfirstnodebyname-returns-none-when-or-is-in-the-name/22437 "2022-03-10T16:40:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![koeglfryderyk](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/koeglfryderyk/32/14638_2.png) [@koeglfryderyk](https://discourse.slicer.org/u/koeglfryderyk)\
**Post date:** [March 10, 2022, 4:40pm UTC](https://discourse.slicer.org/t/getfirstnodebyname-returns-none-when-or-is-in-the-name/22437/1 "2022-03-10T16:40:47Z")

</div>

Is it a feature or a bug that slicer.util.getFirstNodeByName() returns None when parentheses are in the name of a node?

---

<div class="post-metadata">

**Author:** ![ebrahim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ebrahim/32/13403_2.png) [@ebrahim](https://discourse.slicer.org/u/ebrahim)\
**Post date:** [March 10, 2022, 4:56pm UTC](https://discourse.slicer.org/t/getfirstnodebyname-returns-none-when-or-is-in-the-name/22437/2 "2022-03-10T16:56:17Z")

</div>

I don’t know if this is intended, but I think it’s because the name is being treated as a regular expression. A workaround is to escape the parentheses by preceding them with a backslash `\`.

For the possible cause:

- see how `exactNameMatch` is set to `False` [here](https://github.com/Slicer/Slicer/blob/df215d43a1349f22f553de3a0a3929f110c13623/Base/Python/slicer/util.py#L1348)
- see regular expression thing [here](https://github.com/Slicer/Slicer/blob/df215d43a1349f22f553de3a0a3929f110c13623/Libs/MRML/Core/vtkMRMLScene.cxx#L1943)

Another workaround is to call `vtkMRMLScene::GetFirstNode` yourself:

````nohighlight
slicer.mrmlScene.GetFirstNode(your_node_name, None, False, True)```
````
