# Question about value.replace problem

**URL:** <https://forum.openrefine.org/t/question-about-value-replace-problem/1399>\
**Category:** Data cleaning and transformations\
**Created:** [March 20, 2024, 2:36pm UTC](https://forum.openrefine.org/t/question-about-value-replace-problem/1399 "2024-03-20T14:36:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![js1980](https://avatars.discourse-cdn.com/v4/letter/j/958977/32.png) [@js1980](https://forum.openrefine.org/u/js1980)\
**Post date:** [March 20, 2024, 2:36pm UTC](https://forum.openrefine.org/t/question-about-value-replace-problem/1399/1 "2024-03-20T14:36:05Z")

</div>

Hello,

I'm stuck on something. I've tried to run the following GREL transformation across all columns in my table (i.e. I choose the "Transform" option under the "All" column):

value.replace("Chatman, Robby F.", "Chatman, Robert F.")

When I run it, the process only converts _some_ the cell values that are Chatman, Robby F. When I use a conventional replace on a single column (i.e Edit cells\>Replace), all values are successfully replaced.

I've found that sometimes I run into issues with find and replace because the spaces in between the strings differ from one string to the other. Namely, sometimes the space is a nonbreaking space, and sometimes they're conventional "space bar" spaces. So If I replace the first with the second, replacing works. However, in this case, I've double checked and all of the strings Chatman, Robby F. have conventional spaces, so the transformation should work.

I've never used the transform function across all columns so maybe I am missing something? My table is about 56,000 rows of data and 20-plus columns--perhaps the transform process times out at a certain limit?

Thanks for any insights you can provide!

---

<div class="post-metadata">

**Author:** ![Martin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/martin/32/7_2.png) [@Martin](https://forum.openrefine.org/u/Martin)\
**Post date:** [March 22, 2024, 1:44pm UTC](https://forum.openrefine.org/t/question-about-value-replace-problem/1399/2 "2024-03-22T13:44:01Z")

</div>

You and add the following GREL `value.replace(/[\p{Zs}\s]+/,' ')` to collapse all consecutive whitespace before applying your transformation.

You can chain your two replaces in a single expression this way:

```auto
value.replace(/[\p{Zs}\s]+/,' ').replace("Chatman, Robby F.", "Chatman, Robert F.")

```

Using the All \> Transform works the same as running the expression on each column individually. Under the Undo/Redo tab, you can confirm how many replace on each column were performed, and confirm if it missed a column or not.

---

<div class="post-metadata">

**Author:** ![js1980](https://avatars.discourse-cdn.com/v4/letter/j/958977/32.png) [@js1980](https://forum.openrefine.org/u/js1980)\
**Post date:** [March 22, 2024, 3:22pm UTC](https://forum.openrefine.org/t/question-about-value-replace-problem/1399/3 "2024-03-22T15:22:07Z")

</div>

Thanks, Martin. I removed any extra whitespace before I ran the transformation. And running it on an individual column, it changes some of the values but not all (same as the global transformation). Furthermore, find and replace works fine on these values in Excel! I'm assuming it's some hidden character/encoding issue that I can't figure out and which Excel forgives but OpenRefine doesn't. So I just wrote a Powershell script to find and replace on multiple values. Anyway, appreciate your response. It remains a mystery but at least I've figured out a workaround.

---

<div class="post-metadata">

**Author:** ![thadguidry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/thadguidry/32/653_2.png) [@thadguidry](https://forum.openrefine.org/u/thadguidry)\
**Post date:** [March 23, 2024, 2:47am UTC](https://forum.openrefine.org/t/question-about-value-replace-problem/1399/4 "2024-03-23T02:47:20Z")

</div>

@js1980 Feel free to 👍 on this issue [Add a new Hidden Chars facet · Issue #5207 · OpenRefine/OpenRefine · GitHub](https://github.com/OpenRefine/OpenRefine/issues/5207)  
if you think it would help you, and add any comments for the Facet design.

---

<div class="post-metadata">

**Author:** ![tfmorris](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/tfmorris/32/17_2.png) [@tfmorris](https://forum.openrefine.org/u/tfmorris)\
**Post date:** [March 26, 2024, 4:56pm UTC](https://forum.openrefine.org/t/question-about-value-replace-problem/1399/5 "2024-03-26T16:56:41Z")

</div>

Facets are a good tool to help debug things like this. If you set up a facet with your regex, you can then examine the non-matching values to see what they have in common.

Another useful tool, particularly if you suspect character encoding issues (e.g. composed vs decomposed Unicode sequences), are Unicode strings inspectors/debuggers, such as:  
[https://apps.timwhitlock.info/unicode/inspect?s=Chatman%2C+Robby+F](https://apps.timwhitlock.info/unicode/inspect?s=Chatman%2C+Robby+F).

Be sure to cut/paste your strings from OpenRefine's cell edit window to make sure that they are unchanged.

Lastly, if it is a Unicode issue, prefixing your regex with the Unicode flag (?U?), as I mention [here](https://github.com/OpenRefine/OpenRefine/issues/1768#issuecomment-654532880) might help.

If you figure out what the issue was, we'd be curious to know.

Tom
