Skip to main content
Added more description to the answer.
Source Link
Sumit Bhatia
  • 5.9k
  • 2
  • 9
  • 25

For the Rich Text Editor field, you can use this PowerShell script and get all the links.

# Get your item here by providing ID
$rootItem = Get-Item -Path "master:" -ID "{56305117-8C9C-4C08-96D5-BB97A8E27419}"

# Regex pattern to check if the value contains any anchor
$anchorTagPattern = '(?is)<a[^>]*>(.*?)<\/a>';

# Get your RTE Field 
$richTextContent = $rootItem.Fields["DB"].Value;

# Match parttern with your RTE field value
$anchorTagPatternMatches = [regex]::Matches($richTextContent, $anchorTagPattern);

# If Pattern matches 
if(![string]::IsNullOrEmpty($anchorTagPatternMatches)) {

# Create a loop and it will give you all the anchors in your RTE
ForEach ($patterns in $anchorTagPatternMatches) {
       # You will get the values of anchors using this. 
       Write-Host $patterns
    
    }
}

The output you will get is this.

<a href="http://test.com">newLink</a>
<a href="http://google.com">newLink</a>
<a href="http://google.com">Google</a>

And you can get other values as well.

enter image description here

For any other field, you can pass your field name like below and get the details of the links.

$richTextContent = $rootItem.Fields["your field"].Value;

For more details refer to this link.

How to update the anchor link text in rich text field using Sitecore Powershell?

For the Rich Text Editor field, you can use this PowerShell script and get all the links.

# Get your item here by providing ID
$rootItem = Get-Item -Path "master:" -ID "{56305117-8C9C-4C08-96D5-BB97A8E27419}"

# Regex pattern to check if the value contains any anchor
$anchorTagPattern = '(?is)<a[^>]*>(.*?)<\/a>';

# Get your RTE Field 
$richTextContent = $rootItem.Fields["DB"].Value;

# Match parttern with your RTE field value
$anchorTagPatternMatches = [regex]::Matches($richTextContent, $anchorTagPattern);

# If Pattern matches 
if(![string]::IsNullOrEmpty($anchorTagPatternMatches)) {

# Create a loop and it will give you all the anchors in your RTE
ForEach ($patterns in $anchorTagPatternMatches) {

    
    }
}

For any other field, you can pass your field name like below and get the details of the links.

$richTextContent = $rootItem.Fields["your field"].Value;

For more details refer to this link.

How to update the anchor link text in rich text field using Sitecore Powershell?

For the Rich Text Editor field, you can use this PowerShell script and get all the links.

# Get your item here by providing ID
$rootItem = Get-Item -Path "master:" -ID "{56305117-8C9C-4C08-96D5-BB97A8E27419}"

# Regex pattern to check if the value contains any anchor
$anchorTagPattern = '(?is)<a[^>]*>(.*?)<\/a>';

# Get your RTE Field 
$richTextContent = $rootItem.Fields["DB"].Value;

# Match parttern with your RTE field value
$anchorTagPatternMatches = [regex]::Matches($richTextContent, $anchorTagPattern);

# If Pattern matches 
if(![string]::IsNullOrEmpty($anchorTagPatternMatches)) {

# Create a loop and it will give you all the anchors in your RTE
ForEach ($patterns in $anchorTagPatternMatches) {
       # You will get the values of anchors using this. 
       Write-Host $patterns
    
    }
}

The output you will get is this.

<a href="http://test.com">newLink</a>
<a href="http://google.com">newLink</a>
<a href="http://google.com">Google</a>

And you can get other values as well.

enter image description here

For any other field, you can pass your field name like below and get the details of the links.

$richTextContent = $rootItem.Fields["your field"].Value;

For more details refer to this link.

How to update the anchor link text in rich text field using Sitecore Powershell?

Source Link
Sumit Bhatia
  • 5.9k
  • 2
  • 9
  • 25

For the Rich Text Editor field, you can use this PowerShell script and get all the links.

# Get your item here by providing ID
$rootItem = Get-Item -Path "master:" -ID "{56305117-8C9C-4C08-96D5-BB97A8E27419}"

# Regex pattern to check if the value contains any anchor
$anchorTagPattern = '(?is)<a[^>]*>(.*?)<\/a>';

# Get your RTE Field 
$richTextContent = $rootItem.Fields["DB"].Value;

# Match parttern with your RTE field value
$anchorTagPatternMatches = [regex]::Matches($richTextContent, $anchorTagPattern);

# If Pattern matches 
if(![string]::IsNullOrEmpty($anchorTagPatternMatches)) {

# Create a loop and it will give you all the anchors in your RTE
ForEach ($patterns in $anchorTagPatternMatches) {

    
    }
}

For any other field, you can pass your field name like below and get the details of the links.

$richTextContent = $rootItem.Fields["your field"].Value;

For more details refer to this link.

How to update the anchor link text in rich text field using Sitecore Powershell?